From dee56defdb82376394f416ccbbf4e0f96d743fbd Mon Sep 17 00:00:00 2001 From: mfaisalkhatri Date: Wed, 29 Apr 2026 09:29:49 +0530 Subject: [PATCH 1/2] fixed the tests, but the website is not working, POST /register api throws 500 due to which the error is not shown --- docker-compose-toolshop-new.yml | 66 +++++++++++++++++++ .../mfaisalkhatri/data/RegistrationData.java | 1 + .../mfaisalkhatri/pages/RegistrationPage.java | 20 ++++-- .../github/mfaisalkhatri/test/BaseTest.java | 2 +- src/test/resources/testdata.json | 3 + 5 files changed, 84 insertions(+), 8 deletions(-) create mode 100644 docker-compose-toolshop-new.yml diff --git a/docker-compose-toolshop-new.yml b/docker-compose-toolshop-new.yml new file mode 100644 index 0000000..54cc23c --- /dev/null +++ b/docker-compose-toolshop-new.yml @@ -0,0 +1,66 @@ +version: '2' +services: + laravel-api: + image: testsmith/practice-software-testing-sprint5-api + environment: + - "PHP_OPCACHE_VALIDATE_TIMESTAMPS=1" + - "DB_PORT=3306" + - "DB_HOST=mariadb" + - "host=localhost" + - DISABLE_LOGGING=${DISABLE_LOGGING} + volumes: + - laravel-app-code:/var/www + + angular-ui: + image: testsmith/practice-software-testing-sprint5-ui + ports: + - 4200:4200 + command: > + bash -c "ng serve --host 0.0.0.0 --port 4200" + + # The Web Server + web: + image: testsmith/practice-software-testing-web + ports: + - 8091:80 + - 8000:81 + depends_on: + - laravel-api + + cron: + image: testsmith/practice-software-testing-cron + restart: always + depends_on: + - mariadb + - laravel-api + volumes: + - laravel-app-code:/var/www + working_dir: /var/www + command: sh -c "crond -f -l 8" + environment: + - "PHP_OPCACHE_VALIDATE_TIMESTAMPS=1" + - "DB_PORT=3306" + - "DB_HOST=mariadb" + - "host=localhost" + - DISABLE_LOGGING=${DISABLE_LOGGING} + + mariadb: + image: yobasystems/alpine-mariadb:10.6.11 + ports: + - 3306:3306 + expose: + - 3306 + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_USER: user + MYSQL_PASSWORD: root + MYSQL_DATABASE: toolshop + + mailcatcher: + image: dockage/mailcatcher:0.9.0 + ports: + - 1025:1025 # smtp server + - 1080:1080 # web ui + +volumes: + laravel-app-code: \ No newline at end of file diff --git a/src/test/java/io/github/mfaisalkhatri/data/RegistrationData.java b/src/test/java/io/github/mfaisalkhatri/data/RegistrationData.java index 02d8796..39bca88 100644 --- a/src/test/java/io/github/mfaisalkhatri/data/RegistrationData.java +++ b/src/test/java/io/github/mfaisalkhatri/data/RegistrationData.java @@ -11,6 +11,7 @@ public class RegistrationData { private String lastName; private String dob; private String street; + private String houseNumber; private String postalCode; private String city; private String state; diff --git a/src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java b/src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java index f4ec987..c7e510e 100644 --- a/src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java +++ b/src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java @@ -29,15 +29,17 @@ public void fillRegistrationForm (final RegistrationData registrationData) { lastNameField ().clear (); lastNameField ().sendKeys (registrationData.getLastName ()); dobField ().sendKeys (registrationData.getDob ()); - streetField ().clear (); - streetField ().sendKeys (registrationData.getStreet ()); + selectCountryVisibleText (registrationData.getCountry ()); postalCodeField ().clear (); postalCodeField ().sendKeys (registrationData.getPostalCode ()); - cityField ().clear (); - cityField ().sendKeys (registrationData.getCity ()); - stateField ().clear (); - stateField ().sendKeys (registrationData.getState ()); - selectCountryVisibleText (registrationData.getCountry ()); + houseNumber().clear(); + houseNumber().sendKeys(registrationData.getHouseNumber()); + //streetField ().clear (); + //streetField ().sendKeys (registrationData.getStreet ()); + //cityField ().clear (); + //cityField ().sendKeys (registrationData.getCity ()); + //stateField ().clear (); + //stateField ().sendKeys (registrationData.getState ()); phoneField ().clear (); phoneField ().sendKeys (registrationData.getPhone ()); emailAddressField ().clear (); @@ -103,6 +105,10 @@ private WebElement registerButton () { return this.driver.findElement (By.cssSelector (".btnSubmit")); } + private WebElement houseNumber () { + return this.driver.findElement(By.id("house_number")); + } + private void selectCountryVisibleText (final String countryName) { new Select (countryField ()).selectByVisibleText (countryName); } diff --git a/src/test/java/io/github/mfaisalkhatri/test/BaseTest.java b/src/test/java/io/github/mfaisalkhatri/test/BaseTest.java index fc1f1a1..681b242 100644 --- a/src/test/java/io/github/mfaisalkhatri/test/BaseTest.java +++ b/src/test/java/io/github/mfaisalkhatri/test/BaseTest.java @@ -21,7 +21,7 @@ public WebDriver getDriver () { @BeforeClass public void setup () { ChromeOptions chromeOptions = new ChromeOptions (); - chromeOptions.addArguments ("--headless=new","--no-sandbox","--window-size=1920,1080"); + //chromeOptions.addArguments ("--headless=new","--no-sandbox","--window-size=1920,1080"); this.driver = new ChromeDriver (chromeOptions); this.driver.manage () diff --git a/src/test/resources/testdata.json b/src/test/resources/testdata.json index 9f985c4..c7d3877 100644 --- a/src/test/resources/testdata.json +++ b/src/test/resources/testdata.json @@ -6,6 +6,7 @@ "dob": "1987-11-19", "street": "11/2, Fort Street", "postalCode": "113445", + "houseNumber": 25, "city": "California", "state": "Holland", "country": "Benin", @@ -20,6 +21,7 @@ "dob": "1985-04-23", "street": "21/4, Dallas Street", "postalCode": "12976", + "houseNumber": 11, "city": "California", "state": "Dallas", "country": "American Samoa", @@ -35,6 +37,7 @@ "street": "30/2, Texas Street", "postalCode": "155642", "city": "California", + "houseNumber": 30, "state": "Duckberg", "country": "Austria", "phone": "0483678", From c7a224557a3ac368202a1eb4b42c015cde7b2809 Mon Sep 17 00:00:00 2001 From: mfaisalkhatri Date: Wed, 29 Apr 2026 14:52:38 +0530 Subject: [PATCH 2/2] fixed the test and updated the docker compose file with the fixes provided by Roy --- docker-compose-toolshop-new.yml | 66 ------------------- docker-compose-toolshop.yml | 33 +++++++++- pom.xml | 2 +- .../github/mfaisalkhatri/test/BaseTest.java | 4 +- .../test/JsonDataProviderTest.java | 2 +- 5 files changed, 36 insertions(+), 71 deletions(-) delete mode 100644 docker-compose-toolshop-new.yml diff --git a/docker-compose-toolshop-new.yml b/docker-compose-toolshop-new.yml deleted file mode 100644 index 54cc23c..0000000 --- a/docker-compose-toolshop-new.yml +++ /dev/null @@ -1,66 +0,0 @@ -version: '2' -services: - laravel-api: - image: testsmith/practice-software-testing-sprint5-api - environment: - - "PHP_OPCACHE_VALIDATE_TIMESTAMPS=1" - - "DB_PORT=3306" - - "DB_HOST=mariadb" - - "host=localhost" - - DISABLE_LOGGING=${DISABLE_LOGGING} - volumes: - - laravel-app-code:/var/www - - angular-ui: - image: testsmith/practice-software-testing-sprint5-ui - ports: - - 4200:4200 - command: > - bash -c "ng serve --host 0.0.0.0 --port 4200" - - # The Web Server - web: - image: testsmith/practice-software-testing-web - ports: - - 8091:80 - - 8000:81 - depends_on: - - laravel-api - - cron: - image: testsmith/practice-software-testing-cron - restart: always - depends_on: - - mariadb - - laravel-api - volumes: - - laravel-app-code:/var/www - working_dir: /var/www - command: sh -c "crond -f -l 8" - environment: - - "PHP_OPCACHE_VALIDATE_TIMESTAMPS=1" - - "DB_PORT=3306" - - "DB_HOST=mariadb" - - "host=localhost" - - DISABLE_LOGGING=${DISABLE_LOGGING} - - mariadb: - image: yobasystems/alpine-mariadb:10.6.11 - ports: - - 3306:3306 - expose: - - 3306 - environment: - MYSQL_ROOT_PASSWORD: root - MYSQL_USER: user - MYSQL_PASSWORD: root - MYSQL_DATABASE: toolshop - - mailcatcher: - image: dockage/mailcatcher:0.9.0 - ports: - - 1025:1025 # smtp server - - 1080:1080 # web ui - -volumes: - laravel-app-code: \ No newline at end of file diff --git a/docker-compose-toolshop.yml b/docker-compose-toolshop.yml index 4c178c8..3bf65f1 100644 --- a/docker-compose-toolshop.yml +++ b/docker-compose-toolshop.yml @@ -7,7 +7,9 @@ services: - "DB_PORT=3306" - "DB_HOST=mariadb" - "host=localhost" - - DISABLE_LOGGING=true + - DISABLE_LOGGING=${DISABLE_LOGGING} + volumes: + - laravel-app-code:/var/www angular-ui: image: testsmith/practice-software-testing-sprint5-ui @@ -16,6 +18,7 @@ services: command: > bash -c "ng serve --host 0.0.0.0 --port 4200" + # The Web Server web: image: testsmith/practice-software-testing-web ports: @@ -23,6 +26,25 @@ services: - 8000:81 depends_on: - laravel-api + volumes: + - laravel-app-code:/var/www + + cron: + image: testsmith/practice-software-testing-cron + restart: always + depends_on: + - mariadb + - laravel-api + volumes: + - laravel-app-code:/var/www + working_dir: /var/www + command: sh -c "crond -f -l 8" + environment: + - "PHP_OPCACHE_VALIDATE_TIMESTAMPS=1" + - "DB_PORT=3306" + - "DB_HOST=mariadb" + - "host=localhost" + - DISABLE_LOGGING=${DISABLE_LOGGING} mariadb: image: yobasystems/alpine-mariadb:10.6.11 @@ -35,3 +57,12 @@ services: MYSQL_USER: user MYSQL_PASSWORD: root MYSQL_DATABASE: toolshop + + mailcatcher: + image: dockage/mailcatcher:0.9.0 + ports: + - 1025:1025 # smtp server + - 1080:1080 # web ui + +volumes: + laravel-app-code: diff --git a/pom.xml b/pom.xml index b116f9f..38b53f4 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ 3.5.5 UTF-8 testng.xml - -Dfile.encoding=UTF-8 -Xdebug -Xnoagent + -Dfile.encoding=UTF-8 diff --git a/src/test/java/io/github/mfaisalkhatri/test/BaseTest.java b/src/test/java/io/github/mfaisalkhatri/test/BaseTest.java index 681b242..49599bb 100644 --- a/src/test/java/io/github/mfaisalkhatri/test/BaseTest.java +++ b/src/test/java/io/github/mfaisalkhatri/test/BaseTest.java @@ -11,7 +11,7 @@ public class BaseTest implements WebDriverProvider { - protected WebDriver driver; + protected WebDriver driver; @Override public WebDriver getDriver () { @@ -21,7 +21,7 @@ public WebDriver getDriver () { @BeforeClass public void setup () { ChromeOptions chromeOptions = new ChromeOptions (); - //chromeOptions.addArguments ("--headless=new","--no-sandbox","--window-size=1920,1080"); + chromeOptions.addArguments ("--headless=new", "--no-sandbox", "--window-size=1920,1080"); this.driver = new ChromeDriver (chromeOptions); this.driver.manage () diff --git a/src/test/java/io/github/mfaisalkhatri/test/JsonDataProviderTest.java b/src/test/java/io/github/mfaisalkhatri/test/JsonDataProviderTest.java index 645b2a8..f7b6da1 100644 --- a/src/test/java/io/github/mfaisalkhatri/test/JsonDataProviderTest.java +++ b/src/test/java/io/github/mfaisalkhatri/test/JsonDataProviderTest.java @@ -32,7 +32,7 @@ public Iterator getValidRegistrationData () { @Test (dataProvider = "getValidRegistrationData") public void testRegistrationPasswordAlert (final RegistrationData registrationData) { this.driver.get ("http://localhost:4200/"); - // this.driver.get ("https://practicesoftwaretesting.com/auth/register"); + // this.driver.get ("https://practicesoftwaretesting.com/auth/register"); HomePage homePage = new HomePage (driver); LoginPage loginPage = homePage.navigateToLoginPage ();