SeeTest uses a custom WebDriver engine for their SeeTest Automation and Appium Studio frameworks. Unfortunately, these custom WebDriver engines are not compatible with the Applitools selenium sdk. However, all is not lost! We have a images sdk to handle cases like this to split the screenshot and validation into steps. The example below is using SeeTest's android example app "eriBank" that comes in Appium Studio.
More information on the images sdk can be found here.
Example Steps:
- Connect a mobile device to your computer. (make sure it's paired with your machine)
- Start Appium Studio.
- Add the device to Appium Studio, if not already. Make sure the status is "Ready".
- Open Intellj or Eclipse.
- Create a new java test class named "SeeTestImagesSdk.java".
- Copy and past the example below into SeeTestImagesSdk.java and add the Pom.xml dependencies.
- Run the "SeeTestImagesSdk' test class.
Java Example:
import com.experitest.appium.*; import io.appium.java_client.remote.AndroidMobileCapabilityType; import io.appium.java_client.remote.MobileCapabilityType; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.By; import org.junit.*; import java.net.URL; import java.net.MalformedURLException; import java.io.File; import java.io.IOException; import org.apache.commons.io.FileUtils; import org.openqa.selenium.OutputType; import com.applitools.eyes.images.Eyes; import com.applitools.eyes.RectangleSize; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; public class SeeTestImagesSdk { private String host = "localhost"; private int port = 8889; private String reportDirectory = "reports"; private String reportFormat = "xml"; private String testName = "Untitled"; protected SeeTestAndroidDriver<SeeTestAndroidElement> driver = null; protected Eyes eyes = new Eyes(); @Before public void setUp() throws MalformedURLException { DesiredCapabilities dc = new DesiredCapabilities(); dc.setCapability(SeeTestCapabilityType.REPORT_DIRECTORY, reportDirectory); dc.setCapability(SeeTestCapabilityType.REPORT_FORMAT, reportFormat); dc.setCapability(SeeTestCapabilityType.TEST_NAME, testName); dc.setCapability(MobileCapabilityType.UDID, "YOUR DEVICE UDID"); dc.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "com.experitest.ExperiBank"); dc.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, ".LoginActivity"); driver = new SeeTestAndroidDriver<>(new URL("http://"+host+":"+port), dc); eyes.setHostOS("Android"); eyes.setApiKey("YOUR APPLITOOLS API KEY"); eyes.setHostApp("eriBank"); Integer width = driver.manage().window().getSize().getWidth(); Integer height = driver.manage().window().getSize().getHeight(); eyes.open("Android eriBank", "AppiumStudio + Images SDK", new RectangleSize(width, height)); } @Test public void BadLogin() { driver.findElement(By.xpath("//*[@id='usernameTextField']")).sendKeys("myusername"); driver.findElement(By.xpath("//*[@id='passwordTextField']")).sendKeys("password"); driver.findElement(By.xpath("//*[@text='Login']")).click(); new WebDriverWait(driver, 60).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@text='Close']"))); File src= driver.getScreenshotAs(OutputType.FILE); String fileName = "test.png"; try { FileUtils.copyFile(src, new File(fileName)); } catch (IOException e) { System.out.println(e.getMessage()); } BufferedImage img; try { img = ImageIO.read(new File(fileName)); eyes.checkImage(img, "Contact-us page"); } catch (IOException e) { System.out.println(e.getMessage()); } eyes.close(); } @After public void tearDown() { driver.quit(); eyes.abortIfNotClosed(); } }
POM.XML:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.seetest</groupId> <artifactId>junit</artifactId> <version>1.0-SNAPSHOT</version> <repositories> <repository> <releases> <enabled>true</enabled> <updatePolicy>always</updatePolicy> <checksumPolicy>fail</checksumPolicy> </releases> <id>Experitest.repo1</id> <name>YourName</name> <url>http://repo.experitest.com:8010/Maven2/</url> <layout>default</layout> </repository> </repositories> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> </dependency> <dependency> <groupId>com.experitest</groupId> <artifactId>seetest-appium</artifactId> <version>10.8</version> </dependency> <dependency> <groupId>com.experitest</groupId> <artifactId>SeeTestClient</artifactId> <version>10.8</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>2.52.0</version> </dependency> <dependency> <groupId>com.applitools</groupId> <artifactId>eyes-images-java3</artifactId> <version>RELEASE</version> </dependency> </dependencies> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.0</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build> </project>