Skip to content

Instantly share code, notes, and snippets.

@jankcat
Created March 16, 2017 19:40
Show Gist options
  • Save jankcat/31fe960192c15bbde77d8237622a3d0a to your computer and use it in GitHub Desktop.
Save jankcat/31fe960192c15bbde77d8237622a3d0a to your computer and use it in GitHub Desktop.
Applitools Eyes with Native Promise Manager And Timeout
/* In the shell script that runs my tests: */
#Disable the Selenium Promise Manager
export SELENIUM_PROMISE_MANAGER=0
/* In my test file */
/*...getConfig into host, capabilities, key vars...*/
let driver = new webdriver.Builder().usingServer(host).withCapabilities(capabilities).build();
let eyes = new Eyes();
eyes.setApiKey(key);
/*...eyes setBatch, setDefaultMatchTimeout, setWaitBeforeScreenshots, setSaveNewTests, setStitchMode, setForceFullPageScreenshot...*/
eyes.open(driver, testName, testArea).then(function (driver) {
const page = new SomePage(driver, eyes);
return page.open(); // basically just: function { this.driver.get('someUrl'); }
.then(()=>page.blink()); // basically just: this.eyes.checkWindow('someStepName');
/*...same code for 7-8 other pages...*/
}).then(function() {
return driver.quit();
.then(()=>{
return new Promise(function(resolve, reject) {
setTimeout(function() {
resolve();
}, timeOutValueInMS);
eyes.close(false).then(()=>{resolve()});
});
})
.then(()=>eyes.abortIfNotClosed());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment