File tree Expand file tree Collapse file tree 11 files changed +196
-104
lines changed
src/test/java/com/browserstack Expand file tree Collapse file tree 11 files changed +196
-104
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ public class SingleTest extends BrowserStackTestNGTest {
10
10
11
11
@ Test
12
12
public void test () throws Exception {
13
- // navigate to bstackdemo
13
+ // navigate to bstackdemo
14
14
driver .get ("https://www.bstackdemo.com" );
15
15
16
16
// Check the title
Original file line number Diff line number Diff line change 10
10
11
11
public class SuiteTest01 extends BrowserStackTestNGTest {
12
12
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
+ }
23
33
}
Original file line number Diff line number Diff line change @@ -12,13 +12,22 @@ public class SuiteTest02 extends BrowserStackTestNGTest {
12
12
13
13
@ Test
14
14
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 );
23
32
}
24
33
}
Original file line number Diff line number Diff line change 10
10
11
11
public class SuiteTest03 extends BrowserStackTestNGTest {
12
12
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
+ }
25
33
}
Original file line number Diff line number Diff line change 10
10
11
11
public class SuiteTest04 extends BrowserStackTestNGTest {
12
12
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
+ }
23
33
}
Original file line number Diff line number Diff line change 10
10
11
11
public class SuiteTest05 extends BrowserStackTestNGTest {
12
12
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
+ }
24
33
}
Original file line number Diff line number Diff line change 10
10
11
11
public class SuiteTest06 extends BrowserStackTestNGTest {
12
12
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
+ }
25
33
}
Original file line number Diff line number Diff line change 10
10
11
11
public class SuiteTest07 extends BrowserStackTestNGTest {
12
12
13
+ @ Test
13
14
@ Test
14
15
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 );
22
33
}
23
34
}
Original file line number Diff line number Diff line change 10
10
11
11
public class SuiteTest08 extends BrowserStackTestNGTest {
12
12
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
+ }
24
33
}
Original file line number Diff line number Diff line change 10
10
11
11
public class SuiteTest09 extends BrowserStackTestNGTest {
12
12
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
+ }
25
33
}
You can’t perform that action at this time.
0 commit comments