I'm running my first ever Nightwatch test as shown in the code below, everything runs fine, selenium types 'wiki' into google and submits the form fine, test passes. However I want it to automatically close the browser window down after the test has finished.
I've tried adding the below:
driver.closeWindow();
However it fails as it cannot recognise the 'closeWindow()' function, I'm finding the documentation to be very lacking (http://ift.tt/2wcbKr9), so I'd be grateful if someone could point out how I need to implement this.
var webdriver = require('selenium-webdriver'),
By = webdriver.By,
Until = webdriver.Until;
var driver = new webdriver.Builder()
.forBrowser('chrome')
.build();
driver.get('http://www.google.com');
driver.findElement(By.name('q')).sendKeys('wiki');
driver.findElement(By.name('btnK')).submit();
driver.wait(check_title, 1000);
function check_title(){
var promise = driver.getTitle().then(function(title) {
if (title === 'wiki - Google Search') {
console.log('success');
return true;
} else {
console.log('fail, title was ' + title);
}
});
return promise;
}
Aucun commentaire:
Enregistrer un commentaire