8000 Added selectors in the class level variable · LambdaTest/java-testng-selenium@3814c12 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3814c12

Browse files
committed
Added selectors in the class level variable
1 parent 129c50a commit 3814c12

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

src/test/java/com/lambdatest/AddProduct.java

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,17 @@ public class AddProduct {
2020

2121

2222
//Elements
23-
protected static final By SHOP_BY_CATEGORY_NAVIGATION = By.cssSelector("shop-by-category");
23+
protected static final By SHOP_BY_CATEGORY_NAVIGATION = By.className("shop-by-category");
24+
protected static final By PHONE_TABLETS_IPOD_NAVIGATION = By.cssSelector(".mz-pure-drawer:first-of-type .navbar-nav>li:nth-of-type(3)");
25+
protected static final By APPLE_MANUFACTURER_FILTER = By.cssSelector("#container .manufacturer .mz-filter-group-content div:first-of-type div");
26+
private static final By FIRST_IPOD_PRODUCT = By.cssSelector(".carousel-item:first-of-type [title='iPod Touch']");
27+
private static final By ADD_TO_CART_FIRST_PRODUCT = By.cssSelector("div[data-view_id='grid'] .product-layout:first-of-type button[title='Add to Cart']");
28+
private static final By VIEW_CART_BUTTON_IN_BOX = By.cssSelector("#notification-box-top .btn-primary");
29+
private static final By CONTINUE_SHOPPING_BUTTON = By.cssSelector("#content .btn-secondary");
30+
private static final By WEBSITE_DISCLAIMER_HEADING_ON_HOME_PAGE = By.xpath("//strong[contains(text(),'This is a dummy website for Web Automation Testing')]");
31+
32+
33+
2434

2535
private String Status = "failed";
2636

@@ -44,20 +54,20 @@ public class AddProduct {
4454
@Test public void addProducts() {
4555
driverHelper.getURL("https://ecommerce-playground.lambdatest.io/");
4656
driverHelper.waitForPresence(SHOP_BY_CATEGORY_NAVIGATION, 30);
47-
driverHelper.click(By.className("shop-by-category"));
48-
driverHelper.click(By.cssSelector(".mz-pure-drawer:first-of-type .navbar-nav>li:nth-of-type(3)"));
49-
driverHelper.click(By.cssSelector("#container .manufacturer .mz-filter-group-content div:first-of-type div"));
50-
driverHelper.mouseHoverOnElement(By.cssSelector(".carousel-item:first-of-type [title='iPod Touch']"));
51-
driverHelper.staleElementRefresh(By.cssSelector(".carousel-item:first-of-type [title='iPod Touch']"));
57+
driverHelper.click(SHOP_BY_CATEGORY_NAVIGATION);
58+
driverHelper.click(PHONE_TABLETS_IPOD_NAVIGATION);
59+
driverHelper.click(APPLE_MANUFACTURER_FILTER);
60+
driverHelper.mouseHoverOnElement(FIRST_IPOD_PRODUCT);
61+
driverHelper.staleElementRefresh(FIRST_IPOD_PRODUCT);
5262
driverHelper.waitForTime(5);
53-
driverHelper.mouseHoverOnElement(By.cssSelector(".carousel-item:first-of-type [title='iPod Touch']"));
54-
driverHelper.waitForClickable(By.cssSelector("div[data-view_id='grid'] .product-layout:first-of-type button[title='Add to Cart']"), 30);
55-
driverHelper.click(By.cssSelector("div[data-view_id='grid'] .product-layout:first-of-type button[title='Add to Cart']"));
56-
driverHelper.click(By.cssSelector("#notification-box-top .btn-primary"));
57-
driverHelper.waitForVisibility(By.cssSelector("#content .btn-secondary"), 30);
58-
driverHelper.click(By.cssSelector("#content .btn-secondary"));
59-
driverHelper.waitForVisibility(By.xpath("//strong[contains(text(),'This is a dummy website for Web Automation Testing')]"), 30);
60-
boolean value = driver.findElement(By.xpath("//strong[contains(text(),'This is a dummy website for Web Automation Testing')]")).isDisplayed();
63+
driverHelper.mouseHoverOnElement(FIRST_IPOD_PRODUCT);
64+
driverHelper.waitForClickable(ADD_TO_CART_FIRST_PRODUCT, 30);
65+
driverHelper.click(ADD_TO_CART_FIRST_PRODUCT);
66+
driverHelper.click(VIEW_CART_BUTTON_IN_BOX);
67+
driverHelper.waitForVisibility(CONTINUE_SHOPPING_BUTTON, 30);
68+
driverHelper.click(CONTINUE_SHOPPING_BUTTON);
69+
driverHelper.waitForVisibility(WEBSITE_DISCLAIMER_HEADING_ON_HOME_PAGE, 30);
70+
boolean value = driver.findElement(WEBSITE_DISCLAIMER_HEADING_ON_HOME_PAGE).isDisplayed();
6171
Assert.assertTrue(value, "Element is not displayed.");
6272
Status = "Passed";
6373
}

0 commit comments

Comments
 (0)
0