Skip to content

Instantly share code, notes, and snippets.

@asargent
Last active May 14, 2018 23:30
Show Gist options
  • Save asargent/54fdbf1dc642621f4b8b333fab22dcff to your computer and use it in GitHub Desktop.
Save asargent/54fdbf1dc642621f4b8b333fab22dcff to your computer and use it in GitHub Desktop.
Applitools Selenium Java
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import com.applitools.eyes.selenium.Eyes;
import com.applitools.eyes.RectangleSize;
public class HelloWorld {
public static void main(String[] args) {
// Open a Chrome browser.
WebDriver driver = new ChromeDriver();
// Initialize the eyes SDK and set your private API key.
Eyes eyes = new Eyes();
eyes.setApiKey("86fee1a8-8dba-4c9a-bb43-3e19fcff330d");
try{
// Start the test and set the browser's viewport size to 800x600.
eyes.open(driver, "Hello World!", "My first Selenium Java test!",
new RectangleSize(800, 600));
// Navigate the browser to the "hello world!" web-site.
driver.get("https://applitools.com/helloworld");
// Visual checkpoint #1.
eyes.checkWindow("Hello!");
// Click the "Click me!" button.
driver.findElement(By.tagName("button")).click();
// Visual checkpoint #2.
eyes.checkWindow("Click!");
// End the test.
eyes.close();
} finally {
// Close the browser.
driver.quit();
// If the test was aborted before eyes.close was called, ends the test as aborted.
eyes.abortIfNotClosed();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment