Skip to content

Commit

Permalink
udpate the formatting for the new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Oct 18, 2023
1 parent 32a59fc commit 2ea9569
Show file tree
Hide file tree
Showing 4 changed files with 245 additions and 228 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,48 @@

public class AuthenticationTest extends TestBase {

@BeforeEach
public void setup(TestInfo testInfo) {
startFirefoxSession(testInfo);
}

@Test
public void signInUnsuccessful() {
driver.get("https://www.saucedemo.com/");

driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("locked_out_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();

WebElement errorElement = driver.findElement(By.cssSelector("[data-test='error']"));
Assertions.assertTrue(errorElement.getText().contains("Sorry, this user has been locked out"),
"Error Not Found");
}

@Test
public void signInSuccessful() {
driver.get("https://www.saucedemo.com/");

driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("standard_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();

Assertions.assertEquals("https://www.saucedemo.com/inventory.html",
driver.getCurrentUrl(),
"Login Not Successful");
}

@Test
public void logout() throws InterruptedException {
driver.get("https://www.saucedemo.com/");
driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("standard_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();
driver.findElement(By.id("react-burger-menu-btn")).click();
Thread.sleep(1000);

driver.findElement(By.id("logout_sidebar_link")).click();

Assertions.assertEquals("https://www.saucedemo.com/",
driver.getCurrentUrl(),
"Logout Not Successful");
}
@BeforeEach
public void setup(TestInfo testInfo) {
startFirefoxSession(testInfo);
}

@Test
public void signInUnsuccessful() {
driver.get("https://www.saucedemo.com/");

driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("locked_out_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();

WebElement errorElement = driver.findElement(By.cssSelector("[data-test='error']"));
Assertions.assertTrue(
errorElement.getText().contains("Sorry, this user has been locked out"), "Error Not Found");
}

@Test
public void signInSuccessful() {
driver.get("https://www.saucedemo.com/");

driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("standard_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();

Assertions.assertEquals(
"https://www.saucedemo.com/inventory.html", driver.getCurrentUrl(), "Login Not Successful");
}

@Test
public void logout() throws InterruptedException {
driver.get("https://www.saucedemo.com/");
driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("standard_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();
driver.findElement(By.id("react-burger-menu-btn")).click();
Thread.sleep(1000);

driver.findElement(By.id("logout_sidebar_link")).click();

Assertions.assertEquals(
"https://www.saucedemo.com/", driver.getCurrentUrl(), "Logout Not Successful");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,81 +6,94 @@

public class CartTest extends TestBase {

@BeforeEach
public void setup(TestInfo testInfo) {
startFirefoxSession(testInfo);
}

@Test
public void addFromProductPage() {
driver.get("https://www.saucedemo.com/");
driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("standard_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();

driver.findElement(By.id("item_1_title_link")).click();

driver.findElement(By.cssSelector("button[data-test='add-to-cart-sauce-labs-bolt-t-shirt']")).click();

Assertions.assertEquals("1",
driver.findElement(By.className("shopping_cart_badge")).getText(),
"Item not correctly added to cart");
}

@Test
public void removeFromProductPage() {
driver.get("https://www.saucedemo.com/");
driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("standard_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();
driver.findElement(By.id("item_1_title_link")).click();
driver.findElement(By.cssSelector("button[data-test='add-to-cart-sauce-labs-bolt-t-shirt']")).click();

driver.findElement(By.cssSelector("button[data-test='remove-sauce-labs-bolt-t-shirt']")).click();

Assertions.assertTrue(driver.findElements(By.className("shopping_cart_badge")).isEmpty(),
"Item not correctly removed from cart");
}

@Test
public void addFromInventoryPage() {
driver.get("https://www.saucedemo.com/");
driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("standard_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();

driver.findElement(By.cssSelector("button[data-test='add-to-cart-sauce-labs-onesie']")).click();

Assertions.assertEquals("1",
driver.findElement(By.className("shopping_cart_badge")).getText());
}

@Test
public void removeFromInventoryPage() {
driver.get("https://www.saucedemo.com/");
driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("standard_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();
driver.findElement(By.cssSelector("button[data-test='add-to-cart-sauce-labs-bike-light']")).click();

driver.findElement(By.cssSelector("button[data-test='remove-sauce-labs-bike-light']")).click();

Assertions.assertTrue(driver.findElements(By.className("shopping_cart_badge")).isEmpty(),
"Shopping Cart is not empty");
}

@Test
public void removeFromCartPage() {
driver.get("https://www.saucedemo.com/");
driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("standard_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();
driver.findElement(By.cssSelector("button[data-test='add-to-cart-sauce-labs-backpack']")).click();
driver.findElement(By.className("shopping_cart_link")).click();

driver.findElement(By.cssSelector("button[data-test='remove-sauce-labs-backpack']")).click();

Assertions.assertTrue(driver.findElements(By.className("shopping_cart_badge")).isEmpty(),
"Shopping Cart is not empty");
}
@BeforeEach
public void setup(TestInfo testInfo) {
startFirefoxSession(testInfo);
}

@Test
public void addFromProductPage() {
driver.get("https://www.saucedemo.com/");
driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("standard_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();

driver.findElement(By.id("item_1_title_link")).click();

driver
.findElement(By.cssSelector("button[data-test='add-to-cart-sauce-labs-bolt-t-shirt']"))
.click();

Assertions.assertEquals(
"1",
driver.findElement(By.className("shopping_cart_badge")).getText(),
"Item not correctly added to cart");
}

@Test
public void removeFromProductPage() {
driver.get("https://www.saucedemo.com/");
driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("standard_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();
driver.findElement(By.id("item_1_title_link")).click();
driver
.findElement(By.cssSelector("button[data-test='add-to-cart-sauce-labs-bolt-t-shirt']"))
.click();

driver
.findElement(By.cssSelector("button[data-test='remove-sauce-labs-bolt-t-shirt']"))
.click();

Assertions.assertTrue(
driver.findElements(By.className("shopping_cart_badge")).isEmpty(),
"Item not correctly removed from cart");
}

@Test
public void addFromInventoryPage() {
driver.get("https://www.saucedemo.com/");
driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("standard_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();

driver.findElement(By.cssSelector("button[data-test='add-to-cart-sauce-labs-onesie']")).click();

Assertions.assertEquals("1", driver.findElement(By.className("shopping_cart_badge")).getText());
}

@Test
public void removeFromInventoryPage() {
driver.get("https://www.saucedemo.com/");
driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("standard_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();
driver
.findElement(By.cssSelector("button[data-test='add-to-cart-sauce-labs-bike-light']"))
.click();

driver.findElement(By.cssSelector("button[data-test='remove-sauce-labs-bike-light']")).click();

Assertions.assertTrue(
driver.findElements(By.className("shopping_cart_badge")).isEmpty(),
"Shopping Cart is not empty");
}

@Test
public void removeFromCartPage() {
driver.get("https://www.saucedemo.com/");
driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("standard_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();
driver
.findElement(By.cssSelector("button[data-test='add-to-cart-sauce-labs-backpack']"))
.click();
driver.findElement(By.className("shopping_cart_link")).click();

driver.findElement(By.cssSelector("button[data-test='remove-sauce-labs-backpack']")).click();

Assertions.assertTrue(
driver.findElements(By.className("shopping_cart_badge")).isEmpty(),
"Shopping Cart is not empty");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,67 +6,72 @@

public class CheckoutTest extends TestBase {

@BeforeEach
public void setup(TestInfo testInfo) {
startFirefoxSession(testInfo);
}
@BeforeEach
public void setup(TestInfo testInfo) {
startFirefoxSession(testInfo);
}

@Test
public void badInfo() {
driver.get("https://www.saucedemo.com/");
driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("standard_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();
driver.findElement(By.cssSelector("button[data-test='add-to-cart-sauce-labs-onesie']")).click();
driver.findElement(By.className("shopping_cart_link")).click();
driver.findElement(By.cssSelector("button[data-test='checkout']")).click();

@Test
public void badInfo() {
driver.get("https://www.saucedemo.com/");
driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("standard_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();
driver.findElement(By.cssSelector("button[data-test='add-to-cart-sauce-labs-onesie']")).click();
driver.findElement(By.className("shopping_cart_link")).click();
driver.findElement(By.cssSelector("button[data-test='checkout']")).click();
driver.findElement(By.cssSelector("input[data-test='continue']")).click();

driver.findElement(By.cssSelector("input[data-test='continue']")).click();
Assertions.assertTrue(
driver
.findElement(By.cssSelector("input[data-test='firstName']"))
.getAttribute("class")
.contains("error"),
"Expected error not found on page");
}

Assertions.assertTrue(driver.findElement(By.cssSelector("input[data-test='firstName']")).getAttribute("class").contains("error"),
"Expected error not found on page");
}
@Test
public void goodInfo() {
driver.get("https://www.saucedemo.com/");
driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("standard_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();
driver.findElement(By.cssSelector("button[data-test='add-to-cart-sauce-labs-onesie']")).click();
driver.findElement(By.className("shopping_cart_link")).click();
driver.findElement(By.cssSelector("button[data-test='checkout']")).click();

@Test
public void goodInfo() {
driver.get("https://www.saucedemo.com/");
driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("standard_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();
driver.findElement(By.cssSelector("button[data-test='add-to-cart-sauce-labs-onesie']")).click();
driver.findElement(By.className("shopping_cart_link")).click();
driver.findElement(By.cssSelector("button[data-test='checkout']")).click();
driver.findElement(By.cssSelector("input[data-test='firstName']")).sendKeys("Luke");
driver.findElement(By.cssSelector("input[data-test='lastName']")).sendKeys("Perry");
driver.findElement(By.cssSelector("input[data-test='postalCode']")).sendKeys("90210");

driver.findElement(By.cssSelector("input[data-test='firstName']")).sendKeys("Luke");
driver.findElement(By.cssSelector("input[data-test='lastName']")).sendKeys("Perry");
driver.findElement(By.cssSelector("input[data-test='postalCode']")).sendKeys("90210");
driver.findElement(By.cssSelector("input[data-test='continue']")).click();

driver.findElement(By.cssSelector("input[data-test='continue']")).click();
Assertions.assertEquals(
"https://www.saucedemo.com/checkout-step-two.html",
driver.getCurrentUrl(),
"Information Submission Unsuccessful");
}

Assertions.assertEquals("https://www.saucedemo.com/checkout-step-two.html",
driver.getCurrentUrl(),
"Information Submission Unsuccessful");
}
@Test
public void completeCheckout() {
driver.get("https://www.saucedemo.com/");
driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("standard_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();
driver.findElement(By.cssSelector("button[data-test='add-to-cart-sauce-labs-onesie']")).click();
driver.findElement(By.className("shopping_cart_link")).click();
driver.findElement(By.cssSelector("button[data-test='checkout']")).click();
driver.findElement(By.cssSelector("input[data-test='firstName']")).sendKeys("Luke");
driver.findElement(By.cssSelector("input[data-test='lastName']")).sendKeys("Perry");
driver.findElement(By.cssSelector("input[data-test='postalCode']")).sendKeys("90210");
driver.findElement(By.cssSelector("input[data-test='continue']")).click();

@Test
public void completeCheckout() {
driver.get("https://www.saucedemo.com/");
driver.findElement(By.cssSelector("input[data-test='username']")).sendKeys("standard_user");
driver.findElement(By.cssSelector("input[data-test='password']")).sendKeys("secret_sauce");
driver.findElement(By.cssSelector("input[data-test='login-button']")).click();
driver.findElement(By.cssSelector("button[data-test='add-to-cart-sauce-labs-onesie']")).click();
driver.findElement(By.className("shopping_cart_link")).click();
driver.findElement(By.cssSelector("button[data-test='checkout']")).click();
driver.findElement(By.cssSelector("input[data-test='firstName']")).sendKeys("Luke");
driver.findElement(By.cssSelector("input[data-test='lastName']")).sendKeys("Perry");
driver.findElement(By.cssSelector("input[data-test='postalCode']")).sendKeys("90210");
driver.findElement(By.cssSelector("input[data-test='continue']")).click();
driver.findElement(By.cssSelector("button[data-test='finish']")).click();

driver.findElement(By.cssSelector("button[data-test='finish']")).click();
Assertions.assertEquals(
"https://www.saucedemo.com/checkout-complete.html", driver.getCurrentUrl());

Assertions.assertEquals("https://www.saucedemo.com/checkout-complete.html", driver.getCurrentUrl());

Assertions.assertTrue(driver.findElement(By.className("complete-text")).isDisplayed());
}
Assertions.assertTrue(driver.findElement(By.className("complete-text")).isDisplayed());
}
}
Loading

0 comments on commit 2ea9569

Please sign in to comment.