UI comparison across multiple resolutions with different dimensions such as Content, Layout, cross browsers is a difficult task with the help of manual testing.
Why should visual testing be automated:
1. Lot of areas needs to be covered such as browsers, devices, screen resolutions, RWDs etc.
2. Manual visual testing is error prone and time taking.
3. In the process of “Continues Deployment”, it is mandatory that every task should be automated.
Features of Applitools:
Now in this article we are going to learn about integrating applitools with selenium.
1. Download the latest version of the Eyes Java Selenium SDK from https://store.applitools.com/download/eyes_selenium_java/ and extract it to a folder of your choice. Add the extracted files to your path.
2. When running tests, make sure to use your personal API key: XFkqR77qRm9GZkvw9STuox8gBrECZt298F1101ur39cioY110
Sample code is as below:
public static void main(String[] args) throws URISyntaxException, InterruptedException {
WebDriver driver = new FirefoxDriver();
Eyes eyes = new Eyes();
// This is your api key, make sure you use it in all your tests.
eyes.setApiKey("XFkqR77qRm9GZkvw9STuox8gBrECZt298F1101ur39cioY110");
try {
// Start visual testing with browser viewport set to 1024x768.
// Make sure to use the returned driver from this point on.
driver = eyes.open(driver, "Applitools", "Test Web Page", new
RectangleSize(1024, 768));
driver.get("http://applitools.com");
// Visual validation point #1
eyes.checkWindow("Main Page");
driver.findElement(By.cssSelector(".features>a")).click();
// Visual validation point #2
eyes.checkWindow("Features page");
// End visual testing. Validate visual correctness.
eyes.close();
} finally {
// Abort test in case of an unexpected error.
eyes.abortIfNotClosed();
driver.quit();
}
}
}
3. after running a test for the first time, it will automatically be saved as a baseline for future test runs. Now run your test again and open Applitools eyes to analyze the changes. For each step either 'Accept New' in case the changes are expected or 'Keep Baseline' in case the changes reflect a bug.
Advantages of this integration:
Why should visual testing be automated:
1. Lot of areas needs to be covered such as browsers, devices, screen resolutions, RWDs etc.
2. Manual visual testing is error prone and time taking.
3. In the process of “Continues Deployment”, it is mandatory that every task should be automated.
In the search of a automated tool for this purpose, many things comes in mind. Particularly, when we think about open source tools, selenium will be the first choice. But we cannot accomplish the task with selenium due to certain limitations such as desktop application support, iOS support, screenshots comparison etc.
Now in Paid tools, there is a tool named applitools which is designed for this particular purpose. The Applitools is the Applitools Eyes automatically validates the correctness of the UI layout, content and appearance on all browsers, devices and screen resolutions, and enables to automate tests that can only be done manually without it.
- Automated testing of all the visual aspects of your application:
- One simple test validates all the fields on a given screen.No need to write separate test for each UI element on the screen
- Easy integration with existing test automation and ALM frameworks:
- Test automation tools: Selenium, Appium, MS Coded UI, HP QTP (coming soon) and more.ALM tools: HP QC, MS TFS, IBM Rational Quality Manager, Atlassian, Rally and more.Cloud testing environments.
- Seamless testing on multiple platforms, screen-resolutions and form-factors:
- Define expected results or volatile areas for one browser, one screen resolution or one form factor and all tests would automatically be updated in all browsers, all screen resolutions and all form factors. Any change in your application should only be approved once in one specific test and all other tests would automatically be updated for all browsers, all screen resolutions and all form factors
- Visual self-explanatory logs:
- No more reading of complex text-based failure logs.
Visual test timeline points you immediately to any failed steps.
Smart visual test playback shows step by step the user actions and the screen displays during a test.
Now in this article we are going to learn about integrating applitools with selenium.
1. Download the latest version of the Eyes Java Selenium SDK from https://store.applitools.com/download/eyes_selenium_java/ and extract it to a folder of your choice. Add the extracted files to your path.
2. When running tests, make sure to use your personal API key: XFkqR77qRm9GZkvw9STuox8gBrECZt298F1101ur39cioY110
Sample code is as below:
public static void main(String[] args) throws URISyntaxException, InterruptedException {
WebDriver driver = new FirefoxDriver();
Eyes eyes = new Eyes();
// This is your api key, make sure you use it in all your tests.
eyes.setApiKey("XFkqR77qRm9GZkvw9STuox8gBrECZt298F1101ur39cioY110");
try {
// Start visual testing with browser viewport set to 1024x768.
// Make sure to use the returned driver from this point on.
driver = eyes.open(driver, "Applitools", "Test Web Page", new
RectangleSize(1024, 768));
driver.get("http://applitools.com");
// Visual validation point #1
eyes.checkWindow("Main Page");
driver.findElement(By.cssSelector(".features>a")).click();
// Visual validation point #2
eyes.checkWindow("Features page");
// End visual testing. Validate visual correctness.
eyes.close();
} finally {
// Abort test in case of an unexpected error.
eyes.abortIfNotClosed();
driver.quit();
}
}
}
3. after running a test for the first time, it will automatically be saved as a baseline for future test runs. Now run your test again and open Applitools eyes to analyze the changes. For each step either 'Accept New' in case the changes are expected or 'Keep Baseline' in case the changes reflect a bug.
Advantages of this integration:
- Single page validation replaces hundreds of lines of validation code and hours of manual testing.
- Automatic maintenance – approved changes are automatically propagated to other tests and execution environments.
- Cognitive vision – avoiding false positives, by ignoring differences that are invisible to the human eye.
- Automatically test your app in multiple languages.
- Easily tests complex application pages including dynamic content, size and moving elements.
- It takes the pressure off manual QA and increases the coverage, test faster & more accurately.
This is one of the effective tool to automate Visual Testing in Mobile, Web, Desktop Applications. Happy Testing :)