diff --git a/.circleci/config.yml b/.circleci/config.yml
new file mode 100644
index 0000000..5cfbf9e
--- /dev/null
+++ b/.circleci/config.yml
@@ -0,0 +1,20 @@
+version: 2.1
+
+orbs:
+ browser-tools: circleci/browser-tools@1.1.0
+
+jobs:
+ build:
+ docker:
+ - image: cimg/openjdk:17.0
+ steps:
+ - browser-tools/install-chrome
+ - checkout
+ - run: |
+ export APPLITOOLS_BATCH_ID=$(echo $CIRCLE_SHA1)
+ mvn clean test
+
+workflows:
+ build-and-test:
+ jobs:
+ - build
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index c45f834..bb8a268 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,7 +14,23 @@
UTF-8
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.22.2
+
+
+
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ 5.9.0
+ test
+
org.junit.jupiter
junit-jupiter-api
@@ -25,11 +41,19 @@
org.seleniumhq.selenium
selenium-java
4.4.0
+ test
io.github.bonigarcia
webdrivermanager
5.3.0
+ test
+
+
+ com.applitools
+ eyes-selenium-java5
+ 5.35.0
+ test
diff --git a/src/test/java/TestCase.java b/src/test/java/TestCase.java
index aac3b3a..9b1528b 100644
--- a/src/test/java/TestCase.java
+++ b/src/test/java/TestCase.java
@@ -1,48 +1,79 @@
+import com.applitools.eyes.*;
+import com.applitools.eyes.selenium.*;
+import com.applitools.eyes.selenium.fluent.Target;
+import com.applitools.eyes.visualgrid.model.DeviceName;
+import com.applitools.eyes.visualgrid.model.ScreenOrientation;
+import com.applitools.eyes.visualgrid.services.RunnerOptions;
+import com.applitools.eyes.visualgrid.services.VisualGridRunner;
import io.github.bonigarcia.wdm.WebDriverManager;
+import org.aopalliance.reflect.Class;
import org.junit.jupiter.api.*;
import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
-import org.openqa.selenium.chrome.ChromeDriver;
+import org.openqa.selenium.chrome.ChromeOptions;
+
+import java.util.Random;
public class TestCase {
- WebDriver driver;
+ private static WebDriver driver;
+ private static BatchInfo myTestBatch;
+ private static EyesRunner testRunner;
+ private static Configuration suiteConfig;
+ Eyes eyes;
+
+ @BeforeAll
+ public static void beforeAll() {
+ ChromeOptions chromeOptions = new ChromeOptions();
+ chromeOptions.addArguments("--headless");
+ driver = WebDriverManager.chromedriver().capabilities(chromeOptions).create();
+ myTestBatch = new BatchInfo("Test Cases");
+ testRunner = new VisualGridRunner(new RunnerOptions().testConcurrency(5));
+ suiteConfig = new Configuration();
+ suiteConfig.setApiKey(System.getenv("APPLITOOLS_API_KEY"));
+ suiteConfig.setBatch(myTestBatch);
+ suiteConfig.setStitchMode(StitchMode.CSS);
+ suiteConfig.addBrowser(1000, 600, BrowserType.CHROME);
+ suiteConfig.addBrowser(1600, 1200, BrowserType.FIREFOX);
+ suiteConfig.addBrowser(1200, 800, BrowserType.SAFARI);
+ suiteConfig.addDeviceEmulation(DeviceName.iPad, ScreenOrientation.LANDSCAPE);
+ suiteConfig.addDeviceEmulation(DeviceName.iPhone_X, ScreenOrientation.PORTRAIT);
+ }
@BeforeEach
- public void beforeEach() {
- driver = WebDriverManager.chromedriver().create();
+ public void beforeEach(TestInfo testInfo) {
+ eyes = new Eyes(testRunner);
+ eyes.setConfiguration(suiteConfig);
+ eyes.open(driver, "My First Tests", testInfo.getTestMethod().get().getName(), new RectangleSize(1000, 600));
}
+
@Test
- public void myTestCase() {
- try {
- driver.get("https://applitools.com/helloworld/");
- WebElement numbers = driver.findElement(By.cssSelector("span.primary"));
- WebElement button = driver.findElement(By.cssSelector("div.section:nth-child(3) > button:nth-child(1)"));
- WebElement titleH = driver.findElement(By.cssSelector("div.fancy:nth-child(1) > span:nth-child(1)"));
- WebElement titleD = driver.findElement(By.cssSelector("div.fancy:nth-child(1) > span:nth-child(11)"));
-
- Assertions.assertEquals(numbers.isDisplayed(), true);
- Assertions.assertEquals(numbers.getText(), "123456");
- Assertions.assertEquals(numbers.getCssValue("color"), "rgba(78, 90, 99, 1)");
-
- Assertions.assertEquals(button.isDisplayed(), true);
- Assertions.assertEquals(button.getText(), "Click me!");
- Assertions.assertEquals(button.getCssValue("color"), "rgba(255, 255, 255, 1)");
-
- Assertions.assertEquals(titleH.isDisplayed(), true);
- Assertions.assertEquals(titleH.getText(), "H");
- Assertions.assertEquals(titleH.getCssValue("color"), "rgba(255, 0, 0, 1)");
-
- Assertions.assertEquals(titleD.isDisplayed(), true);
- Assertions.assertEquals(titleD.getText(), "D");
- Assertions.assertEquals(titleD.getCssValue("color"), "rgba(70, 0, 255, 1)");
- } catch(Exception e) {
- Assertions.fail(e);
- }
+ public void autoMaintenance() {
+ driver.get("https://applitools.com/helloworld");
+
+ JavascriptExecutor jsExec = (JavascriptExecutor) driver;
+ jsExec.executeScript("document.querySelector('div.fancy:nth-child(1)').style.backgroundColor = 'lightGray';");
+
+ eyes.check(Target.window());
+
+ WebElement button = driver.findElement(By.cssSelector("div.section:nth-child(3) > button:nth-child(1)"));
+ button.click();
+ eyes.check(Target.window());
+
+ button.click();
+ eyes.check(Target.window());
}
@AfterEach
public void afterEach() {
+ eyes.closeAsync();
+ }
+
+ @AfterAll
+ public static void afterAll() {
driver.close();
+ TestResultsSummary results = testRunner.getAllTestResults();
+ System.out.println(results);
}
}
diff --git a/target/test-classes/TestCase.class b/target/test-classes/TestCase.class
index 9904316..95daa51 100644
Binary files a/target/test-classes/TestCase.class and b/target/test-classes/TestCase.class differ