Skip to content

Commit e93dfb2

Browse files
RutvikChandlafrancisf
authored andcommitted
changes suite code
1 parent 6d6a588 commit e93dfb2

File tree

11 files changed

+196
-104
lines changed

11 files changed

+196
-104
lines changed

src/test/java/com/browserstack/SingleTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class SingleTest extends BrowserStackTestNGTest {
1010

1111
@Test
1212
public void test() throws Exception {
13-
// navigate to bstackdemo
13+
// navigate to bstackdemo
1414
driver.get("https://www.bstackdemo.com");
1515

1616
// Check the title

src/test/java/com/browserstack/suite/SuiteTest01.java

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,24 @@
1010

1111
public class SuiteTest01 extends BrowserStackTestNGTest {
1212

13-
@Test
14-
public void test_01() throws Exception {
15-
driver.get("https://www.google.com/ncr");
16-
WebElement element = driver.findElement(By.name("q"));
17-
element.sendKeys("BrowserStack Test 01");
18-
element.submit();
19-
Thread.sleep(5000);
20-
21-
Assert.assertEquals("BrowserStack Test 01 - Google Search", driver.getTitle());
22-
}
13+
@Test
14+
public void test_01() throws Exception {
15+
// navigate to bstackdemo
16+
driver.get("https://www.bstackdemo.com");
17+
18+
// Check the title
19+
Assert.assertTrue(driver.getTitle().matches("StackDemo"));
20+
21+
// Save the text of the product for later verify
22+
String productOnScreenText = driver.findElement(By.xpath("//*[@id=\"1\"]/p")).getText();
23+
// Click on add to cart button
24+
driver.findElement(By.xpath("//*[@id=\"1\"]/div[4]")).click();
25+
26+
// See if the cart is opened or not
27+
Assert.assertTrue(driver.findElement(By.className("float-cart__content")).isDisplayed());
28+
29+
// Check the product inside the cart is same as of the main page
30+
String productOnCartText = driver.findElement(By.xpath("//*[@id=\"__next\"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]")).getText();
31+
Assert.assertEquals(productOnScreenText, productOnCartText);
32+
}
2333
}

src/test/java/com/browserstack/suite/SuiteTest02.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,22 @@ public class SuiteTest02 extends BrowserStackTestNGTest {
1212

1313
@Test
1414
public void test_02() throws Exception {
15-
driver.get("https://www.google.com/ncr");
16-
Thread.sleep(5000);
17-
WebElement element = driver.findElement(By.name("q"));
18-
element.sendKeys("BrowserStack Test 02");
19-
element.submit();
20-
Thread.sleep(5000);
21-
22-
Assert.assertEquals("BrowserStack Test 02 - Google Search", driver.getTitle());
15+
// navigate to bstackdemo
16+
driver.get("https://www.bstackdemo.com");
17+
18+
// Check the title
19+
Assert.assertTrue(driver.getTitle().matches("StackDemo"));
20+
21+
// Save the text of the product for later verify
22+
String productOnScreenText = driver.findElement(By.xpath("//*[@id=\"1\"]/p")).getText();
23+
// Click on add to cart button
24+
driver.findElement(By.xpath("//*[@id=\"1\"]/div[4]")).click();
25+
26+
// See if the cart is opened or not
27+
Assert.assertTrue(driver.findElement(By.className("float-cart__content")).isDisplayed());
28+
29+
// Check the product inside the cart is same as of the main page
30+
String productOnCartText = driver.findElement(By.xpath("//*[@id=\"__next\"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]")).getText();
31+
Assert.assertEquals(productOnScreenText, productOnCartText);
2332
}
2433
}

src/test/java/com/browserstack/suite/SuiteTest03.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,24 @@
1010

1111
public class SuiteTest03 extends BrowserStackTestNGTest {
1212

13-
@Test
14-
public void test_03() throws Exception {
15-
driver.get("https://www.google.com/ncr");
16-
Thread.sleep(5000);
17-
WebElement element = driver.findElement(By.name("q"));
18-
element.sendKeys("BrowserStack Test 03");
19-
Thread.sleep(5000);
20-
element.submit();
21-
Thread.sleep(5000);
22-
23-
Assert.assertEquals("BrowserStack Test 03 - Google Search", driver.getTitle());
24-
}
13+
@Test
14+
public void test_03() throws Exception {
15+
// navigate to bstackdemo
16+
driver.get("https://www.bstackdemo.com");
17+
18+
// Check the title
19+
Assert.assertTrue(driver.getTitle().matches("StackDemo"));
20+
21+
// Save the text of the product for later verify
22+
String productOnScreenText = driver.findElement(By.xpath("//*[@id=\"1\"]/p")).getText();
23+
// Click on add to cart button
24+
driver.findElement(By.xpath("//*[@id=\"1\"]/div[4]")).click();
25+
26+
// See if the cart is opened or not
27+
Assert.assertTrue(driver.findElement(By.className("float-cart__content")).isDisplayed());
28+
29+
// Check the product inside the cart is same as of the main page
30+
String productOnCartText = driver.findElement(By.xpath("//*[@id=\"__next\"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]")).getText();
31+
Assert.assertEquals(productOnScreenText, productOnCartText);
32+
}
2533
}

src/test/java/com/browserstack/suite/SuiteTest04.java

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,24 @@
1010

1111
public class SuiteTest04 extends BrowserStackTestNGTest {
1212

13-
@Test
14-
public void test_04() throws Exception {
15-
driver.get("https://www.google.com/ncr");
16-
WebElement element = driver.findElement(By.name("q"));
17-
element.sendKeys("BrowserStack Test 04");
18-
element.submit();
19-
Thread.sleep(7000);
20-
21-
Assert.assertEquals("BrowserStack Test 04 - Google Search", driver.getTitle());
22-
}
13+
@Test
14+
public void test_04() throws Exception {
15+
// navigate to bstackdemo
16+
driver.get("https://www.bstackdemo.com");
17+
18+
// Check the title
19+
Assert.assertTrue(driver.getTitle().matches("StackDemo"));
20+
21+
// Save the text of the product for later verify
22+
String productOnScreenText = driver.findElement(By.xpath("//*[@id=\"1\"]/p")).getText();
23+
// Click on add to cart button
24+
driver.findElement(By.xpath("//*[@id=\"1\"]/div[4]")).click();
25+
26+
// See if the cart is opened or not
27+
Assert.assertTrue(driver.findElement(By.className("float-cart__content")).isDisplayed());
28+
29+
// Check the product inside the cart is same as of the main page
30+
String productOnCartText = driver.findElement(By.xpath("//*[@id=\"__next\"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]")).getText();
31+
Assert.assertEquals(productOnScreenText, productOnCartText);
32+
}
2333
}

src/test/java/com/browserstack/suite/SuiteTest05.java

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,24 @@
1010

1111
public class SuiteTest05 extends BrowserStackTestNGTest {
1212

13-
@Test
14-
public void test_05() throws Exception {
15-
driver.get("https://www.google.com/ncr");
16-
Thread.sleep(7000);
17-
WebElement element = driver.findElement(By.name("q"));
18-
element.sendKeys("BrowserStack Test 05");
19-
element.submit();
20-
Thread.sleep(7000);
21-
22-
Assert.assertEquals("BrowserStack Test 05 - Google Search", driver.getTitle());
23-
}
13+
@Test
14+
public void test_05() throws Exception {
15+
// navigate to bstackdemo
16+
driver.get("https://www.bstackdemo.com");
17+
18+
// Check the title
19+
Assert.assertTrue(driver.getTitle().matches("StackDemo"));
20+
21+
// Save the text of the product for later verify
22+
String productOnScreenText = driver.findElement(By.xpath("//*[@id=\"1\"]/p")).getText();
23+
// Click on add to cart button
24+
driver.findElement(By.xpath("//*[@id=\"1\"]/div[4]")).click();
25+
26+
// See if the cart is opened or not
27+
Assert.assertTrue(driver.findElement(By.className("float-cart__content")).isDisplayed());
28+
29+
// Check the product inside the cart is same as of the main page
30+
String productOnCartText = driver.findElement(By.xpath("//*[@id=\"__next\"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]")).getText();
31+
Assert.assertEquals(productOnScreenText, productOnCartText);
32+
}
2433
}

src/test/java/com/browserstack/suite/SuiteTest06.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,24 @@
1010

1111
public class SuiteTest06 extends BrowserStackTestNGTest {
1212

13-
@Test
14-
public void test_06() throws Exception {
15-
driver.get("https://www.google.com/ncr");
16-
Thread.sleep(7000);
17-
WebElement element = driver.findElement(By.name("q"));
18-
element.sendKeys("BrowserStack Test 06");
19-
Thread.sleep(7000);
20-
element.submit();
21-
Thread.sleep(7000);
22-
23-
Assert.assertEquals("BrowserStack Test 06 - Google Search", driver.getTitle());
24-
}
13+
@Test
14+
public void test_06() throws Exception {
15+
// navigate to bstackdemo
16+
driver.get("https://www.bstackdemo.com");
17+
18+
// Check the title
19+
Assert.assertTrue(driver.getTitle().matches("StackDemo"));
20+
21+
// Save the text of the product for later verify
22+
String productOnScreenText = driver.findElement(By.xpath("//*[@id=\"1\"]/p")).getText();
23+
// Click on add to cart button
24+
driver.findElement(By.xpath("//*[@id=\"1\"]/div[4]")).click();
25+
26+
// See if the cart is opened or not
27+
Assert.assertTrue(driver.findElement(By.className("float-cart__content")).isDisplayed());
28+
29+
// Check the product inside the cart is same as of the main page
30+
String productOnCartText = driver.findElement(By.xpath("//*[@id=\"__next\"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]")).getText();
31+
Assert.assertEquals(productOnScreenText, productOnCartText);
32+
}
2533
}

src/test/java/com/browserstack/suite/SuiteTest07.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,25 @@
1010

1111
public class SuiteTest07 extends BrowserStackTestNGTest {
1212

13+
@Test
1314
@Test
1415
public void test_07() throws Exception {
15-
driver.get("https://www.google.com/ncr");
16-
WebElement element = driver.findElement(By.name("q"));
17-
element.sendKeys("BrowserStack Test 07");
18-
element.submit();
19-
Thread.sleep(3000);
20-
21-
Assert.assertEquals("BrowserStack Test 07 - Google Search", driver.getTitle());
16+
// navigate to bstackdemo
17+
driver.get("https://www.bstackdemo.com");
18+
19+
// Check the title
20+
Assert.assertTrue(driver.getTitle().matches("StackDemo"));
21+
22+
// Save the text of the product for later verify
23+
String productOnScreenText = driver.findElement(By.xpath("//*[@id=\"1\"]/p")).getText();
24+
// Click on add to cart button
25+
driver.findElement(By.xpath("//*[@id=\"1\"]/div[4]")).click();
26+
27+
// See if the cart is opened or not
28+
Assert.assertTrue(driver.findElement(By.className("float-cart__content")).isDisplayed());
29+
30+
// Check the product inside the cart is same as of the main page
31+
String productOnCartText = driver.findElement(By.xpath("//*[@id=\"__next\"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]")).getText();
32+
Assert.assertEquals(productOnScreenText, productOnCartText);
2233
}
2334
}

src/test/java/com/browserstack/suite/SuiteTest08.java

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,24 @@
1010

1111
public class SuiteTest08 extends BrowserStackTestNGTest {
1212

13-
@Test
14-
public void test_08() throws Exception {
15-
driver.get("https://www.google.com/ncr");
16-
Thread.sleep(3000);
17-
WebElement element = driver.findElement(By.name("q"));
18-
element.sendKeys("BrowserStack Test 08");
19-
element.submit();
20-
Thread.sleep(3000);
21-
22-
Assert.assertEquals("BrowserStack Test 08 - Google Search", driver.getTitle());
23-
}
13+
@Test
14+
public void test_08() throws Exception {
15+
// navigate to bstackdemo
16+
driver.get("https://www.bstackdemo.com");
17+
18+
// Check the title
19+
Assert.assertTrue(driver.getTitle().matches("StackDemo"));
20+
21+
// Save the text of the product for later verify
22+
String productOnScreenText = driver.findElement(By.xpath("//*[@id=\"1\"]/p")).getText();
23+
// Click on add to cart button
24+
driver.findElement(By.xpath("//*[@id=\"1\"]/div[4]")).click();
25+
26+
// See if the cart is opened or not
27+
Assert.assertTrue(driver.findElement(By.className("float-cart__content")).isDisplayed());
28+
29+
// Check the product inside the cart is same as of the main page
30+
String productOnCartText = driver.findElement(By.xpath("//*[@id=\"__next\"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]")).getText();
31+
Assert.assertEquals(productOnScreenText, productOnCartText);
32+
}
2433
}

src/test/java/com/browserstack/suite/SuiteTest09.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,24 @@
1010

1111
public class SuiteTest09 extends BrowserStackTestNGTest {
1212

13-
@Test
14-
public void test_09() throws Exception {
15-
driver.get("https://www.google.com/ncr");
16-
Thread.sleep(3000);
17-
WebElement element = driver.findElement(By.name("q"));
18-
element.sendKeys("BrowserStack Test 09");
19-
Thread.sleep(3000);
20-
element.submit();
21-
Thread.sleep(3000);
22-
23-
Assert.assertEquals("BrowserStack Test 09 - Google Search", driver.getTitle());
24-
}
13+
@Test
14+
public void test_09() throws Exception {
15+
// navigate to bstackdemo
16+
driver.get("https://www.bstackdemo.com");
17+
18+
// Check the title
19+
Assert.assertTrue(driver.getTitle().matches("StackDemo"));
20+
21+
// Save the text of the product for later verify
22+
String productOnScreenText = driver.findElement(By.xpath("//*[@id=\"1\"]/p")).getText();
23+
// Click on add to cart button
24+
driver.findElement(By.xpath("//*[@id=\"1\"]/div[4]")).click();
25+
26+
// See if the cart is opened or not
27+
Assert.assertTrue(driver.findElement(By.className("float-cart__content")).isDisplayed());
28+
29+
// Check the product inside the cart is same as of the main page
30+
String productOnCartText = driver.findElement(By.xpath("//*[@id=\"__next\"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]")).getText();
31+
Assert.assertEquals(productOnScreenText, productOnCartText);
32+
}
2533
}

0 commit comments

Comments
 (0)