@@ -20,7 +20,17 @@ public class AddProduct {
20
20
21
21
22
22
//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
+
24
34
25
35
private String Status = "failed" ;
26
36
@@ -44,20 +54,20 @@ public class AddProduct {
44
54
@ Test public void addProducts () {
45
55
driverHelper .getURL ("https://ecommerce-playground.lambdatest.io/" );
46
56
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 );
52
62
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 ();
61
71
Assert .assertTrue (value , "Element is not displayed." );
62
72
Status = "Passed" ;
63
73
}
0 commit comments