Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f0fb64f

Browse files
Added all the selectors in the varible
1 parent 3814c12 commit f0fb64f

File tree

6 files changed

+155
-101
lines changed

6 files changed

+155
-101
lines changed

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@ public class AddProduct {
2323
protected static final By SHOP_BY_CATEGORY_NAVIGATION = By.className("shop-by-category");
2424
protected static final By PHONE_TABLETS_IPOD_NAVIGATION = By.cssSelector(".mz-pure-drawer:first-of-type .navbar-nav>li:nth-of-type(3)");
2525
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-
26+
protected static final By FIRST_IPOD_PRODUCT = By.cssSelector(".carousel-item:first-of-type [title='iPod Touch']");
27+
protected 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+
protected static final By VIEW_CART_BUTTON_IN_BOX = By.cssSelector("#notification-box-top .btn-primary");
29+
protected static final By CONTINUE_SHOPPING_BUTTON = By.cssSelector("#content .btn-secondary");
30+
protected static final By WEBSITE_DISCLAIMER_HEADING_ON_HOME_PAGE = By.xpath("//strong[contains(text(),'This is a dummy website for Web Automation Testing')]");
3431

3532
private String Status = "failed";
3633

‎src/test/java/com/lambdatest/CompareProducts.java

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,23 @@ public class CompareProducts {
1717
private RemoteWebDriver driver;
1818
WebDriverHelper driverHelper;
1919

20-
2120
private String Status = "failed";
2221

23-
@BeforeMethod
24-
public void setup(Method m, ITestContext ctx) throws MalformedURLException {
22+
//Elements
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(
25+
".mz-pure-drawer:first-of-type .navbar-nav>li:nth-of-type(3)");
26+
protected static final By HTC_TOUCH_ID_FIRST_PRODUCT = By.cssSelector(
27+
".carousel-item:first-of-type [title='HTC Touch HD']");
28+
protected static final By COMPARE_TO_THIS_PRODUCT_OPTION = By.cssSelector(
29+
"div[data-view_id='grid'] .product-layout:first-of-type button[title='Compare this Product']");
30+
protected static final By APPLE_MANUFACTURER_FILTER = By.cssSelector(
31+
"#container .manufacturer .mz-filter-group-content div:first-of-type div");
32+
protected static final By FIRST_IPOD_PRODUCT = By.cssSelector(".carousel-item:first-of-type [title='iPod Touch']");
33+
protected static final By COMPARE_PRODUCT_BUTTON = By.cssSelector("#notification-box-top a.btn-secondary");
34+
protected static final By PRODUCT_COMPARISON_HEADING = By.cssSelector(".h4");
35+
36+
@BeforeMethod public void setup(Method m, ITestContext ctx) throws MalformedURLException {
2537
String username = System.getenv("LT_USERNAME") == null ? "Your LT Username" : System.getenv("LT_USERNAME");
2638
String authKey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" : System.getenv("LT_ACCESS_KEY");
2739
String hub = "@hub.lambdatest.com/wd/hub";
@@ -38,24 +50,22 @@ public void setup(Method m, ITestContext ctx) throws MalformedURLException {
3850
driverHelper = new WebDriverHelper(driver);
3951
}
4052

41-
@Test
42-
public void compareProducts() {
53+
@Test public void compareProducts() {
4354
driverHelper.getURL("https://ecommerce-playground.lambdatest.io/");
44-
driverHelper.click(By.cssSelector("shop-by-category"));
45-
driverHelper.click(By.cssSelector(".mz-pure-drawer:first-of-type .navbar-nav>li:nth-of-type(3)"));
46-
driverHelper.click(By.cssSelector(".carousel-item:first-of-type [title='HTC Touch HD']"));
47-
driverHelper.mouseHoverOnElement(By.cssSelector(".carousel-item:first-of-type [title='HTC Touch HD']"));
48-
driverHelper.click(By.cssSelector("div[data-view_id='grid'] .product-layout:first-of-type button[title='Compare this Product']"));
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.click(By.cssSelector("div[data-view_id='grid'] .product-layout:first-of-type button[title='Compare this Product']"));
52-
driverHelper.click(By.cssSelector("#notification-box-top a.btn-secondary"));
53-
driverHelper.isDisplayed(By.cssSelector(".h4"));
55+
driverHelper.click(SHOP_BY_CATEGORY_NAVIGATION);
56+
driverHelper.click(PHONE_TABLETS_IPOD_NAVIGATION);
57+
driverHelper.click(HTC_TOUCH_ID_FIRST_PRODUCT);
58+
driverHelper.mouseHoverOnElement(HTC_TOUCH_ID_FIRST_PRODUCT);
59+
driverHelper.click(COMPARE_TO_THIS_PRODUCT_OPTION);
60+
driverHelper.click(APPLE_MANUFACTURER_FILTER);
61+
driverHelper.mouseHoverOnElement(FIRST_IPOD_PRODUCT);
62+
driverHelper.click(COMPARE_TO_THIS_PRODUCT_OPTION);
63+
driverHelper.click(COMPARE_PRODUCT_BUTTON);
64+
driverHelper.isDisplayed(PRODUCT_COMPARISON_HEADING);
5465
Status = "Passed";
5566
}
5667

57-
@AfterMethod
58-
public void tearDown() {
68+
@AfterMethod public void tearDown() {
5969
driver.executeScript("lambda-status=" + Status);
6070
driver.quit();
6171
}

‎src/test/java/com/lambdatest/ProductFilters.java

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,17 @@ public class ProductFilters {
1818
private RemoteWebDriver driver;
1919
WebDriverHelper driverHelper;
2020

21+
// ELEMENTS
22+
protected static final By SHOP_BY_CATEGORY_NAVIGATION = By.className("shop-by-category");
23+
protected static final By MINIMUM_PRICE_FILTER_INPUT_FIELD = By.cssSelector("#container input[name='mz_fp[min]']");
24+
protected static final By MAXIMUM_PRICE_FILTER_INPUT_FIELD = By.cssSelector("#container input[name='mz_fp[min]']");
25+
protected static final By APPLE_MANUFACTURER_FILTER = By.cssSelector(
26+
"#container .manufacturer .mz-filter-group-content div:first-of-type div");
27+
protected static final By PHONES_AND_PDAs_FILTER = By.cssSelector("#container .module-category a:nth-of-type(5)");
28+
2129
private String Status = "failed";
2230

23-
@BeforeMethod
24-
public void setup(Method m, ITestContext ctx) throws MalformedURLException {
31+
@BeforeMethod public void setup(Method m, ITestContext ctx) throws MalformedURLException {
2532
String username = System.getenv("LT_USERNAME") == null ? "Your LT Username" : System.getenv("LT_USERNAME");
2633
String authKey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" : System.getenv("LT_ACCESS_KEY");
2734
String hub = "@hub.lambdatest.com/wd/hub";
@@ -38,21 +45,22 @@ public void setup(Method m, ITestContext ctx) throws MalformedURLException {
3845
driverHelper = new WebDriverHelper(driver);
3946
}
4047

41-
@Test
42-
public void productFilters() {
48+
@Test public void productFilters() {
4349
driverHelper.getURL("https://ecommerce-playground.lambdatest.io/");
44-
driverHelper.click(By.cssSelector("#container input[name='mz_fp[min]']"));
45-
driverHelper.sendKeys(By.cssSelector("#container input[name='mz_fp[min]']"), "0");
46-
driverHelper.clearInputField(By.cssSelector("#container input[name='mz_fp[max]']"));
47-
driverHelper.sendKeys(By.cssSelector("#container input[name='mz_fp[max]']"), "200");
48-
driverHelper.sendKeysByKeyBoard(By.cssSelector("#container input[name='mz_fp[max]']"), Keys.ENTER);
49-
driverHelper.click(By.cssSelector("#container .manufacturer .mz-filter-group-content div:first-of-type div"));
50-
driverHelper.click(By.cssSelector("#container .module-category a:nth-of-type(5)"));
50+
driverHelper.waitForPresence(SHOP_BY_CATEGORY_NAVIGATION, 30);
51+
driverHelper.click(SHOP_BY_CATEGORY_NAVIGATION);
52+
driverHelper.waitForPresence(MINIMUM_PRICE_FILTER_INPUT_FIELD, 30);
53+
driverHelper.clearInputField(MINIMUM_PRICE_FILTER_INPUT_FIELD);
54+
driverHelper.sendKeys(MINIMUM_PRICE_FILTER_INPUT_FIELD, "0");
55+
driverHelper.clearInputField(MAXIMUM_PRICE_FILTER_INPUT_FIELD);
56+
driverHelper.sendKeys(MAXIMUM_PRICE_FILTER_INPUT_FIELD, "200");
57+
driverHelper.sendKeysByKeyBoard(MAXIMUM_PRICE_FILTER_INPUT_FIELD, Keys.ENTER);
58+
driverHelper.click(APPLE_MANUFACTURER_FILTER);
59+
driverHelper.click(PHONES_AND_PDAs_FILTER);
5160
Status = "Passed";
5261
}
5362

54-
@AfterMethod
55-
public void tearDown() {
63+
@AfterMethod public void tearDown() {
5664
driver.executeScript("lambda-status=" + Status);
5765
driver.quit();
5866
}

‎src/test/java/com/lambdatest/ProductPage.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.openqa.selenium.By;
55
import org.openqa.selenium.remote.DesiredCapabilities;
66
import org.openqa.selenium.remote.RemoteWebDriver;
7+
import org.testng.Assert;
78
import org.testng.ITestContext;
89
import org.testng.annotations.AfterMethod;
910
import org.testng.annotations.BeforeMethod;
@@ -17,10 +18,17 @@ public class ProductPage {
1718
private RemoteWebDriver driver;
1819
WebDriverHelper driverHelper;
1920

21+
//Elements
22+
protected static final By SHOP_BY_CATEGORY_NAVIGATION = By.className("shop-by-category");
23+
protected static final By PHONE_TABLETS_IPOD_NAVIGATION = By.cssSelector(
24+
".mz-pure-drawer:first-of-type .navbar-nav>li:nth-of-type(3)");
25+
protected static final By APPLE_MANUFACTURER_FILTER = By.cssSelector(
26+
"#container .manufacturer .mz-filter-group-content div:first-of-type div");
27+
protected static final By PRODUCT_PAGE_IMAGE = By.cssSelector("[title='Tablets']");
28+
2029
private String Status = "failed";
2130

22-
@BeforeMethod
23-
public void setup(Method m, ITestContext ctx) throws MalformedURLException {
31+
@BeforeMethod public void setup(Method m, ITestContext ctx) throws MalformedURLException {
2432
String username = System.getenv("LT_USERNAME") == null ? "Your LT Username" : System.getenv("LT_USERNAME");
2533
String authKey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" : System.getenv("LT_ACCESS_KEY");
2634
String hub = "@hub.lambdatest.com/wd/hub";
@@ -37,18 +45,17 @@ public void setup(Method m, ITestContext ctx) throws MalformedURLException {
3745
driverHelper = new WebDriverHelper(driver);
3846
}
3947

40-
@Test
41-
public void searchProduct() {
48+
@Test public void productPage() {
4249
driverHelper.getURL("https://ecommerce-playground.lambdatest.io/");
43-
driverHelper.click(By.cssSelector("shop-by-category"));
44-
driverHelper.click(By.cssSelector(".mz-pure-drawer:first-of-type .navbar-nav>li:nth-of-type(3)"));
45-
driverHelper.click(By.cssSelector("#container .manufacturer .mz-filter-group-content div:first-of-type div"));
46-
driverHelper.click(By.cssSelector(".order-1 .btn-cart"));
50+
driverHelper.click(SHOP_BY_CATEGORY_NAVIGATION);
51+
driverHelper.click(PHONE_TABLETS_IPOD_NAVIGATION);
52+
driverHelper.click(APPLE_MANUFACTURER_FILTER);
53+
Assert.assertTrue(driverHelper.isDisplayed(PRODUCT_PAGE_IMAGE), "Product page is not displayed.");
54+
;
4755
Status = "Passed";
4856
}
4957

50-
@AfterMethod
51-
public void tearDown() {
58+
@AfterMethod public void tearDown() {
5259
driver.executeScript("lambda-status=" + Status);
5360
driver.quit();
5461
}

‎src/test/java/com/lambdatest/RegisterAccount.java

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,21 @@
1616
public class RegisterAccount {
1717
private RemoteWebDriver driver;
1818
WebDriverHelper driverHelper;
19+
20+
//Elements
21+
protected static final By MY_ACCOUNT_DROP_DOWN = By.cssSelector("#main-navigation a[href*='account/account']");
22+
protected static final By REGISTER_LINK_TEXT = By.cssSelector("#column-right a[href*='account/register']");
23+
protected static final By FIRST_NAME_INPUT_FIELD = By.id("input-firstname");
24+
protected static final By LAST_NAME_INPUT_FIELD = By.id("input-lastname");
25+
protected static final By EMAIL_INPUT_FIELD = By.id("input-email");
26+
protected static final By TELEPHONE_INPUT_FIELD = By.id("input-telephone");
27+
protected static final By PASSWORD_INPUT_FIELD = By.id("input-password");
28+
protected static final By CONFIRM_PASSWORD_INPUT_FIELD = By.id("input-confirm");
29+
protected static final By PRIVACY_POLICY_CHECKBOX = By.id("input-agree");
30+
protected static final By CONTINUE_BUTTON = By.id("input[type='submit']");
1931
private String Status = "failed";
2032

21-
@BeforeMethod
22-
public void setup(Method m, ITestContext ctx) throws MalformedURLException {
33+
@BeforeMethod public void setup(Method m, ITestContext ctx) throws MalformedURLException {
2334
String username = System.getenv("LT_USERNAME") == null ? "Your LT Username" : System.getenv("LT_USERNAME");
2435
String authKey = System.getenv("LT_ACCESS_KEY") == null ? "Your LT AccessKey" : System.getenv("LT_ACCESS_KEY");
2536
String hub = "@hub.lambdatest.com/wd/hub";
@@ -36,25 +47,23 @@ public void setup(Method m, ITestContext ctx) throws MalformedURLException {
3647
driverHelper = new WebDriverHelper(driver);
3748
}
3849

39-
@Test(priority = 1)
40-
public void register() {
50+
@Test(priority = 1) public void register() {
4151
driverHelper.getURL("https://ecommerce-playground.lambdatest.io/");
42-
driverHelper.click(By.cssSelector("#main-navigation a[href*='account/account']"));
43-
driverHelper.click(By.cssSelector("#column-right a[href*='account/register']"));
44-
driverHelper.waitForPresence(By.id("input-firstname"), 30);
45-
driverHelper.sendKeys(By.id("input-firstname"), "name");
46-
driverHelper.sendKeys(By.id("input-lastname"), "LastName");
47-
driverHelper.sendKeys(By.id("input-email"), "Email");
48-
driverHelper.sendKeys(By.id("input-telephone"), "Number");
49-
driverHelper.sendKeys(By.id("input-password"), "Password");
50-
driverHelper.sendKeys(By.id("input-confirm"), "Confirm password");
51-
// driverHelper.click(By.id("input-agree"));
52-
driverHelper.click(By.cssSelector("input[type='submit']"));
52+
driverHelper.click(MY_ACCOUNT_DROP_DOWN);
53+
driverHelper.click(REGISTER_LINK_TEXT);
54+
driverHelper.waitForPresence(FIRST_NAME_INPUT_FIELD, 30);
55+
driverHelper.sendKeys(FIRST_NAME_INPUT_FIELD, "name");
56+
driverHelper.sendKeys(LAST_NAME_INPUT_FIELD, "LastName");
57+
driverHelper.sendKeys(EMAIL_INPUT_FIELD, "Email");
58+
driverHelper.sendKeys(TELEPHONE_INPUT_FIELD, "Number");
59+
driverHelper.sendKeys(PASSWORD_INPUT_FIELD, "Password");
60+
driverHelper.sendKeys(CONFIRM_PASSWORD_INPUT_FIELD, "Confirm password");
61+
// driverHelper.click(PRIVACY_POLICY_CHECKBOX);
62+
driverHelper.click(CONTINUE_BUTTON);
5363
Status = "Passed";
5464
}
5565

56-
@AfterMethod
57-
public void tearDown() {
66+
@AfterMethod public void tearDown() {
5867
driver.executeScript("lambda-status=" + Status);
5968
driver.quit();
6069
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /