Skip to content

Instantly share code, notes, and snippets.

Last active February 25, 2020 16:53
What would you like to do?
Visual UI Test Script Appium Applitools AWS Device Farm
"use strict";
;(async () => {
const webdriver = require("selenium-webdriver");
const LOCAL_APPIUM = "";
// Initialize the eyes SDK and set your private API key.
const { Eyes, Target, FileLogHandler, BatchInfo, StitchMode } = require("@applitools/eyes-selenium");
const batchInfo = new BatchInfo("AWS Device Farm"); = process.env.BATCH_ID
batchInfo.setSequenceName('AWS Device Farm Batches');
// Initialize the eyes SDK
let eyes = new Eyes();
eyes.setLogHandler(new FileLogHandler(true));
const capabilities = {
platformName: "Android",
deviceName: "Android Emulator",
automationName: "UiAutomator2",
browserName: 'Chrome',
waitforTimeout: 30000,
commandTimeout: 30000,
if (process.env.APPIUM_ENV === "Local") {
capabilities["avd"] = 'Pixel_XL_API_29';
// Open browser.
let driver = new webdriver
try {
// Start the test
await, ' Conferences', 'Appium on Android');
await driver.get('');
// Visual checkpoint #1.
await eyes.check('Home Page', Target.window());
// display title of the page
await driver.getTitle().then(function (title) {
console.log("Title: ", title);
// locate and click the burger button
await driver.wait(webdriver.until.elementLocated(webdriver.By.tagName('button.navbar__burger')), 2000).click();
// locate and click the hyperlink with href='/#location' inside the second nav element
await driver.wait(webdriver.until.elementLocated(webdriver.By.xpath("//nav[2]/ul/li[3]/a[contains(text(), 'Location')]")), 2000).click();
const h2 = await driver.wait(webdriver.until.elementLocated(webdriver.By.xpath("(//h2[@class='section-title'])[4]")), 2000);
console.log("H2 Text: ", await h2.getText());
// Visual checkpoint #2.
await eyes.check('Home Loans', Target.window());
// Close Eyes
await eyes.close();
} catch (error) {
} finally {
// Close the browser.
await driver.quit();
// If the test was aborted before eyes.close was called, ends the test as aborted.
await eyes.abort();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment