Skip to content

Instantly share code, notes, and snippets.

@alfonsodev
Last active January 2, 2016 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alfonsodev/8233972 to your computer and use it in GitHub Desktop.
Save alfonsodev/8233972 to your computer and use it in GitHub Desktop.
example of chrome-driver web fixed
var webdriver = require('selenium-webdriver');
var flow = webdriver.promise.controlFlow();
var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
driver.get('http://www.google.com');
driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');
driver.findElement(webdriver.By.name('btnG')).click();
driver.wait(function() {
return driver.getTitle().then(function(title) {
return title === 'webdriver - Buscar con Google';
});
}, 4000);
flow.on('uncaughtException', function(err) {
console.log('There was an uncaught exception: ' + err);
});
driver.quit();
var assert = require('assert'),
test = require('selenium-webdriver/testing'),
webdriver = require('selenium-webdriver'),
flow = webdriver.promise.controlFlow();
test.describe('Google Search', function() {
var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
test.it('should work', function(done) {
driver.get('http://www.google.com');
var searchBox = driver.findElement(webdriver.By.name('q'));
searchBox.sendKeys('webdriver');
searchBox.getAttribute('value').then(function(value) {
assert.equal(value, 'webdriver');
});
});
test.after(function(){
driver.quit();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment