Applitools Eyes SDK For Selenium JavaScript WebDriver
Install eyes.selenium as a local dev dependency in your tested project:
npm install eyes.selenium
Add Eyes to your tests, for example - when directly using selenium-webdriver:
var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
var Eyes = require('eyes.selenium').Eyes;
var eyes = new Eyes();
eyes.setApiKey("<YOUR_API_KEY>");
eyes.open(driver, "JavaScript SDK", "Simple JS SDK Test").then(function(driver) {
driver.get('http://www.google.com');
eyes.checkWindow("Google");
driver.get('http://www.nba.com');
eyes.checkWindow("NBA");
eyes.close();
driver.quit();
});
Eyes.Selenium.JavaScript also allow you to use Protractor in your tests. First you have to install Protractor dependencies:
npm install -g selenium-webdriver protractor
Then you can use next example:
var Eyes = require('eyes.selenium').Eyes;
var eyes = new Eyes();
eyes.setApiKey("<YOUR_API_KEY>");
describe('angularjs homepage', function() {
it('should add one and two', function() {
eyes.open(browser, "JavaScript SDK", "Simple Protractor Test");
browser.get('http://juliemr.github.io/protractor-demo/');
eyes.checkWindow("Demo start");
element(by.model('first')).sendKeys(1);
element(by.model('second')).sendKeys(2);
eyes.checkWindow("Input Ready");
element(by.id('gobutton')).click();
eyes.checkWindow("Result");
expect(element(by.binding('latest')).getText()).toEqual('3');
eyes.close();
});
});
For more details, please, see Protractor documentation.
Note: older Protractor versions may require passing protractor.getInstance().driver
instead of browser
to eyes.open()