Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.DS_Store
/target/
/target/
/.idea
/SeleniumJavaDemoApp.iml
15 changes: 1 addition & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,12 @@
<name>Java-tutorial</name>
<url>http://maven.apache.org</url>

<!-- Use JDK 10 -->
<properties>
<maven.compiler.source>10</maven.compiler.source>
<maven.compiler.target>10</maven.compiler.target>
</properties>

<dependencies>
<!-- This is the Applitools Selenium Java SDK -->
<dependency>
<groupId>com.applitools</groupId>
<artifactId>eyes-selenium-java3</artifactId>
<version>3.151.2</version>
<version>3.160.0</version>
</dependency>
<!-- Required to run "mvn package" which runs test -->
<dependency>
Expand All @@ -30,12 +24,5 @@
<scope>test</scope>
</dependency>

<!-- Required for Java 10 -->
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>

</dependencies>
</project>
110 changes: 0 additions & 110 deletions src/main/java/com/applitools/quickstarts/VisualGridDemo.java

This file was deleted.

102 changes: 76 additions & 26 deletions src/test/java/com/applitools/quickstarts/AppTest.java
Original file line number Diff line number Diff line change
@@ -1,38 +1,88 @@
package com.applitools.quickstarts;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import com.applitools.eyes.TestResultsSummary;
import com.applitools.eyes.selenium.BrowserType;
import com.applitools.eyes.selenium.Configuration;
import com.applitools.eyes.selenium.Eyes;
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.VisualGridRunner;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
public class AppTest
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
@Test
public void VGTest()
{
super( testName );
}
// Create a new webdriver
WebDriver webDriver = new ChromeDriver();

/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
// Navigate to the url we want to test
webDriver.get("https://demo.applitools.com");

/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
// ⭐️ Note to see visual bugs, run the test using the above URL for the 1st run.
//but then change the above URL to https://demo.applitools.com/index_v2.html (for the 2nd run)

// Create a runner with concurrency of 10
VisualGridRunner runner = new VisualGridRunner(10);

// Create Eyes object with the runner, meaning it'll be a Visual Grid eyes.
Eyes eyes = new Eyes(runner);

// Get current Eyes configuration object
Configuration conf = eyes.getConfiguration();


//conf.setApiKey("APPLITOOLS_API_KEY"); // Set the Applitools API KEY here or as an environment variable "APPLITOOLS_API_KEY"
conf.setTestName("Java VisualGrid demo") // Set test name
.setAppName("Demo app"); // Set app name

// Add browsers with different viewports
conf.addBrowser(800, 600, BrowserType.CHROME);
conf.addBrowser(700, 500, BrowserType.FIREFOX);
conf.addBrowser(1200, 800, BrowserType.IE_10);
conf.addBrowser(1600, 1200, BrowserType.IE_11);
conf.addBrowser(1024, 768, BrowserType.EDGE);
conf.addBrowser(800, 600, BrowserType.SAFARI);

// Add iPhone 4 device emulation in Portrait mode
conf.addDeviceEmulation(DeviceName.iPhone_4, ScreenOrientation.PORTRAIT);


// Set the configuration object to eyes
eyes.setConfiguration(conf);

try
{
// Call Open on eyes to initialize a test session
eyes.open(webDriver);

// check the login page
eyes.check(Target.window().fully().withName("Login page"));
webDriver.findElement(By.id("log-in")).click();

// Check the app page
eyes.check(Target.window().fully().withName("App page"));

// Call Close on eyes to let the server know it should display the results
eyes.closeAsync();
}
finally
{
// Close the browser
webDriver.quit();
}

// Wait and collect all test results
TestResultsSummary allTestResults = runner.getAllTestResults();
System.out.println(allTestResults);
}

}