Skip to content

Commit c1e345a

Browse files
committed
check element only
1 parent cf093c2 commit c1e345a

File tree

5 files changed

+45
-8
lines changed

5 files changed

+45
-8
lines changed

resources/test.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
################
22
# MY APP #
33
################
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
57

68
################
79
# SELENIUM #

src/test/java/DynamicTests.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import base.BaseTests;
2+
import com.applitools.eyes.MatchLevel;
23
import org.junit.Test;
34

45
public class DynamicTests extends BaseTests {
56

7+
private String APP_NAME = "The Internet";
8+
69
@Test
710
public void testDynamicContent(){
8-
validateWindow();
11+
driver.get(System.getProperty("site.dynamic.url"));
12+
eyes.setMatchLevel(MatchLevel.LAYOUT);
13+
validateWindow(APP_NAME);
914
}
1015
}

src/test/java/ScrollTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33

44
public class ScrollTests extends BaseTests {
55

6+
private String APP_NAME = "The Internet";
7+
68
@Test
79
public void testLargeDom() {
8-
validateWindow();
10+
driver.get(System.getProperty("site.largedom.url"));
11+
validateWindow(APP_NAME);
912
}
1013
}

src/test/java/SearchTests.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
11
import base.BaseTests;
2+
import org.junit.Assert;
3+
import org.junit.BeforeClass;
24
import org.junit.Test;
5+
import org.openqa.selenium.By;
6+
import pages.SearchPage;
37

48
public class SearchTests extends BaseTests {
59

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+
618
@Test
719
public void testSearchByFullTitle(){
820
String title = "Agile Testing";
921
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());
1132
}
1233
}

src/test/java/base/BaseTests.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.applitools.eyes.selenium.Eyes;
44
import org.junit.AfterClass;
55
import org.junit.BeforeClass;
6+
import org.openqa.selenium.By;
67
import org.openqa.selenium.WebDriver;
78
import org.openqa.selenium.chrome.ChromeDriver;
89

@@ -28,8 +29,6 @@ public static void setUp() {
2829

2930
driver = new ChromeDriver();
3031
initiateEyes();
31-
32-
driver.get(System.getProperty("site.url"));
3332
}
3433

3534
@AfterClass
@@ -43,10 +42,17 @@ private static void initiateEyes(){
4342
eyes.setApiKey(System.getProperty("applitools.api.key"));
4443
}
4544

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());
4847
eyes.setForceFullPageScreenshot(true);
4948
eyes.checkWindow();
5049
eyes.close();
5150
}
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+
5258
}

0 commit comments

Comments
 (0)