File tree Expand file tree Collapse file tree 5 files changed +45
-8
lines changed Expand file tree Collapse file tree 5 files changed +45
-8
lines changed Original file line number Diff line number Diff line change 1
1
# ###############
2
2
# MY APP #
3
3
# ###############
4
- site.url =https://the-internet.herokuapp.com/large
4
+ site.bookstore.url =file:///Users/angie/workspace/test_automation_u/visual_validation_course/website/index.html
5
+ site.largedom.url =https://the-internet.herokuapp.com/large
6
+ site.dynamic.url =https://the-internet.herokuapp.com/dynamic_content
5
7
6
8
# ###############
7
9
# SELENIUM #
Original file line number Diff line number Diff line change 1
1
import base .BaseTests ;
2
+ import com .applitools .eyes .MatchLevel ;
2
3
import org .junit .Test ;
3
4
4
5
public class DynamicTests extends BaseTests {
5
6
7
+ private String APP_NAME = "The Internet" ;
8
+
6
9
@ Test
7
10
public void testDynamicContent (){
8
- validateWindow ();
11
+ driver .get (System .getProperty ("site.dynamic.url" ));
12
+ eyes .setMatchLevel (MatchLevel .LAYOUT );
13
+ validateWindow (APP_NAME );
9
14
}
10
15
}
Original file line number Diff line number Diff line change 3
3
4
4
public class ScrollTests extends BaseTests {
5
5
6
+ private String APP_NAME = "The Internet" ;
7
+
6
8
@ Test
7
9
public void testLargeDom () {
8
- validateWindow ();
10
+ driver .get (System .getProperty ("site.largedom.url" ));
11
+ validateWindow (APP_NAME );
9
12
}
10
13
}
Original file line number Diff line number Diff line change 1
1
import base .BaseTests ;
2
+ import org .junit .Assert ;
3
+ import org .junit .BeforeClass ;
2
4
import org .junit .Test ;
5
+ import org .openqa .selenium .By ;
6
+ import pages .SearchPage ;
3
7
4
8
public class SearchTests extends BaseTests {
5
9
10
+ private String APP_NAME = "Automation Bookstore" ;
11
+ private SearchPage page = new SearchPage (driver );
12
+
13
+ @ BeforeClass
14
+ public static void launchApp (){
15
+ driver .get (System .getProperty ("site.bookstore.url" ));
16
+ }
17
+
6
18
@ Test
7
19
public void testSearchByFullTitle (){
8
20
String title = "Agile Testing" ;
9
21
page .search (title );
10
- validateWindow ();
22
+ validateWindow (APP_NAME );
23
+ }
24
+
25
+ @ Test
26
+ public void testSearchByFullTitle_Element (){
27
+ String title = "Agile Testing" ;
28
+ page .search (title );
29
+ validateElement (By .id ("pid3" ));
30
+ Assert .assertEquals ("Number of books returned" ,
31
+ 1 , page .getNumberOfVisibleBooks ());
11
32
}
12
33
}
Original file line number Diff line number Diff line change 3
3
import com .applitools .eyes .selenium .Eyes ;
4
4
import org .junit .AfterClass ;
5
5
import org .junit .BeforeClass ;
6
+ import org .openqa .selenium .By ;
6
7
import org .openqa .selenium .WebDriver ;
7
8
import org .openqa .selenium .chrome .ChromeDriver ;
8
9
@@ -28,8 +29,6 @@ public static void setUp() {
28
29
29
30
driver = new ChromeDriver ();
30
31
initiateEyes ();
31
-
32
- driver .get (System .getProperty ("site.url" ));
33
32
}
34
33
35
34
@ AfterClass
@@ -43,10 +42,17 @@ private static void initiateEyes(){
43
42
eyes .setApiKey (System .getProperty ("applitools.api.key" ));
44
43
}
45
44
46
- public void validateWindow (){
47
- eyes .open (driver , "The Internet" , Thread .currentThread ().getStackTrace ()[2 ].getMethodName ());
45
+ public void validateWindow (String appName ){
46
+ eyes .open (driver , appName , Thread .currentThread ().getStackTrace ()[2 ].getMethodName ());
48
47
eyes .setForceFullPageScreenshot (true );
49
48
eyes .checkWindow ();
50
49
eyes .close ();
51
50
}
51
+
52
+ public void validateElement (By locator ){
53
+ eyes .open (driver , "Automation Bookstore" , Thread .currentThread ().getStackTrace ()[2 ].getMethodName ());
54
+ eyes .checkElement (locator );
55
+ eyes .close ();
56
+ }
57
+
52
58
}
You can’t perform that action at this time.
0 commit comments