Updated driver options, updated the code for isPetNameDisplayed function, applied formatter with no issues

This commit is contained in:
Marko 2024-05-17 16:22:52 +02:00
parent 8e27420b0a
commit beaee8e390
8 changed files with 33 additions and 16 deletions

View file

@ -59,11 +59,13 @@ public class TestBase {
String browser = prop.getProperty("browser").toLowerCase();
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--headless", "-disable-gpu", "-window-size=1920,1080");
chromeOptions.addArguments("--headless=new", "-disable-gpu", "-window-size=1920,1080", "--lang=en");
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.addArguments("--headless", "-disable-gpu", "-window-size=1920,1080");
firefoxOptions.addArguments("--headless", "-disable-gpu", "-window-size=1920,1080", "--lang=en");
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.addArguments("--headless", "-disable-gpu", "-window-size=1920,1080");
edgeOptions.addArguments("--headless=new", "-disable-gpu", "-window-size=1920,1080", "--lang=en");
switch (browser) {
case "chrome":
@ -79,7 +81,7 @@ public class TestBase {
throw new IllegalArgumentException("Unsupported browser: " + browser);
}
// driver.manage().window().maximize();
driver.manage().window().maximize();
driver.get(prop.getProperty("testUrl"));
WebElement welcomePhoto = driver.findElement(By.className(locators.getProperty("welcomePhoto")));
@ -92,4 +94,5 @@ public class TestBase {
public void tearDown() {
driver.quit();
}
}

View file

@ -1,7 +1,5 @@
welcomePhoto=http://localhost:8080/resources/images/pets.png
ownerNotFoundText=has not been found
Owner1=George Franklin 110 W. Liberty St. Madison 6085551023 Leo
Owner2=Betty Davis 638 Cardinal Ave. Sun Prairie 6085551749 Basil
successMessage=New Owner Created
errorMessage=must not be blank
errorMessageTelephoneField=numeric value out of bounds (<10 digits>.<0 digits> expected)

View file

@ -14,7 +14,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOf;
public class ListOwnersPage extends TestBase {
public ListOwnersPage(WebDriver driver, Properties loc) {

View file

@ -83,10 +83,10 @@ public class OwnerPage extends TestBase {
}
public boolean isPetNameDisplayed(String petName) {
WebElement petDetails = driver.findElement(petDetailsClass);
String petDetailsText = petDetails.getText();
List<WebElement> petDetails = driver.findElements(petDetailsClass);
List<String> petDetailsText = petDetails.stream().map(WebElement::getText).toList();
String expectedPetName = input.getProperty(petName);
return petDetailsText.contains(expectedPetName);
return petDetailsText.stream().anyMatch(petDetailsItem -> petDetailsItem.contains(expectedPetName));
}
public void clickOnEditPetButton() {

View file

@ -1,6 +1,7 @@
package selenium.scenarios;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import selenium.TestBase;
import selenium.pages.AddOwnerPage;
@ -13,7 +14,9 @@ import static org.junit.Assert.*;
public class AddOwnerTest extends TestBase {
private AddOwnerPage addOwnerPage;
private OwnerPage ownerPage;
private FindOwnersPage findOwnersPage;
@Before
@ -39,7 +42,8 @@ public class AddOwnerTest extends TestBase {
addOwnerPage.setTextInFields(firstNameText, lastNameText, addressText, cityText, telephoneText);
if (action.equalsIgnoreCase("add")) {
addOwnerPage.clickingOnAddOwnerButton();
} else if (action.equalsIgnoreCase("update")) {
}
else if (action.equalsIgnoreCase("update")) {
addOwnerPage.clickOnUpdateOwnerButton();
}
}
@ -64,6 +68,7 @@ public class AddOwnerTest extends TestBase {
// User is still created after putting numbers in the name fields - REPORT DEFECT!!!
@Test
@Ignore("Disabled due to defect")
public void testNumbersInNameFields() {
navigateToAddOwner();
@ -74,6 +79,7 @@ public class AddOwnerTest extends TestBase {
// You can add the same owner twice - REPORT DEFECT!!!
@Test
@Ignore("Disabled due to defect")
public void testCreateSameOwnerTwice() {
navigateToAddOwner();
@ -115,6 +121,7 @@ public class AddOwnerTest extends TestBase {
// User can still be updated - REPORT DEFECT!!!
@Test
@Ignore("Disabled due to defect")
public void testUpdateOwnerWithSameDetailsFromOtherOwner() {
findOwnersPage.navigateToFindOwnersPage();
findOwnersPage.clickOnFindOwnerButton();
@ -144,4 +151,5 @@ public class AddOwnerTest extends TestBase {
assertTrue(ownerPage.isUpdateMessageDisplayed());
assertTrue(ownerPage.isLastNameDisplayed(input.getProperty("updateLastName2")));
}
}

View file

@ -1,6 +1,7 @@
package selenium.scenarios;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import selenium.TestBase;
import selenium.pages.*;
@ -10,8 +11,11 @@ import static org.junit.Assert.*;
public class AddPetTest extends TestBase {
private AddOwnerPage addOwnerPage;
private OwnerPage ownerPage;
private FindOwnersPage findOwnersPage;
private AddPetPage addPetPage;
@Before
@ -30,7 +34,8 @@ public class AddPetTest extends TestBase {
addPetPage.fillTheFields(petNameText, petBirthDateText, petTypeOption);
if (action.equalsIgnoreCase("add")) {
addPetPage.clickOnAddPetButton();
} else if (action.equalsIgnoreCase("update")) {
}
else if (action.equalsIgnoreCase("update")) {
addPetPage.clickOnUpdatePetButton();
}
}
@ -103,6 +108,7 @@ public class AddPetTest extends TestBase {
// Pet is still added after putting numbers in 'Name' field - REPORT DEFECT!!!
@Test
@Ignore("Disabled due to defect")
public void testAddNumbersInNameField() {
navigateToAddPetForExistingOwner(1);

View file

@ -10,7 +10,9 @@ import static org.junit.Assert.assertTrue;
public class AddVisitTest extends TestBase {
private OwnerPage ownerPage;
private FindOwnersPage findOwnersPage;
private AddVisitPage addVisitPage;
@Before

View file

@ -11,6 +11,7 @@ import static org.junit.Assert.assertTrue;
public class HomePageTest extends TestBase {
private HomePage homePage;
private FindOwnersPage findOwnersPage;
@Before