Skip to content

Instantly share code, notes, and snippets.

@dmidlo
Last active May 23, 2017 18:03
Show Gist options
  • Save dmidlo/c8e5e0f556c769f03788559dbb4c35bb to your computer and use it in GitHub Desktop.
Save dmidlo/c8e5e0f556c769f03788559dbb4c35bb to your computer and use it in GitHub Desktop.
let webdriver = require('selenium-webdriver'),
chrome = require('selenium-webdriver/chrome'),
By = webdriver.By
until = webdriver.until;
let options = new chrome.Options();
options.setChromeBinaryPath('/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary');
options.addArguments(['headless','disable-gpu']);
let driver = new webdriver.Builder().forBrowser('chrome').setChromeOptions(options).build();
let baseURL = 'https://www.google.com';
driver.get(baseURL)
//ref: http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/until.html
let button = driver.wait(() => {
return driver.findElement({name:'btnK'}).isEnabled()
}).then(() => {
driver.findElement({name:'btnK'}).click()
})
// returns:
// .../node_modules/selenium-webdriver/lib/promise.js:2634
// throw error;
// ^
//
//TypeError: element.isEnabled is not a function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment