Created
January 19, 2019 00:53
-
-
Save manoj9788/42e5f068c61060a6480033d5c6bc6fcf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.applitools.eyes.appium; | |
import com.applitools.eyes.LogHandler; | |
import com.applitools.eyes.ProxySettings; | |
import com.applitools.eyes.StdoutLogHandler; | |
import io.appium.java_client.MobileBy; | |
import io.appium.java_client.MobileElement; | |
import io.appium.java_client.Setting; | |
import io.appium.java_client.TouchAction; | |
import io.appium.java_client.android.AndroidDriver; | |
import java.net.URL; | |
import java.time.Duration; | |
import java.util.concurrent.TimeUnit; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.remote.DesiredCapabilities; | |
import org.openqa.selenium.remote.RemoteWebDriver; | |
public class AppiumAndroidFullPageScreenshotTest { | |
public static void main(String[] args) throws Exception { | |
// Set desired capabilities. | |
DesiredCapabilities capabilities = new DesiredCapabilities(); | |
capabilities.setCapability("platformName", "Android"); | |
capabilities.setCapability("deviceName", "Google Nexus 6"); | |
capabilities.setCapability("platformVersion", "6.0"); | |
capabilities.setCapability("app", "/Users/manoj/Documents/applitools/appium-test-apps/android-appium-demo/app-debug.apk"); | |
capabilities.setCapability("automationName", "UiAutomator2"); | |
capabilities.setCapability("newCommandTimeout", 300); | |
// Open the app. | |
AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); | |
driver.manage().timeouts().implicitlyWait(5000, TimeUnit.MILLISECONDS); | |
// Initialize the eyes SDK and set your private API key. | |
Eyes eyes = new Eyes(); | |
eyes.setApiKey(System.getenv("APPLITOOLS_API_KEY")); | |
eyes.setLogHandler(new StdoutLogHandler(true)); | |
eyes.setForceFullPageScreenshot(true); | |
eyes.setMatchTimeout(1000); | |
eyes.setSaveDebugScreenshots(true); | |
try { | |
// Start the test. | |
EyesAppiumDriver appiumDriver = (EyesAppiumDriver) eyes.open(driver, "Applitools Demo", "Appium Native Android with Full Page Screenshot"); | |
eyes.checkWindow("scroll"); | |
// End the test. | |
eyes.close(); | |
} finally { | |
// Close the app. | |
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