Created
October 27, 2019 03:05
-
-
Save BooookStore/67b26734c95759572cdaf11edb801ccf to your computer and use it in GitHub Desktop.
headless chrome + selenium + webdriverio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const selenium = require('selenium-standalone'); | |
const {remote} = require('webdriverio'); | |
selenium.install((result) => console.log({result})); | |
selenium.start((err, child) => { | |
(async () => { | |
const browser = await remote({ | |
logLevel: 'trace', | |
capabilities: { | |
browserName: 'chrome', | |
'goog:chromeOptions': { | |
args: ['--headless'] | |
} | |
} | |
}) | |
await browser.url('https://duckduckgo.com') | |
const inputElem = await browser.$('#search_form_input_homepage') | |
await inputElem.setValue('WebdriverIO') | |
const submitBtn = await browser.$('#search_button_homepage') | |
await submitBtn.click() | |
console.log(await browser.getTitle()) // outputs: "Title is: WebdriverIO (Software) at DuckDuckGo" | |
await browser.deleteSession() | |
child.kill(); | |
})().catch((e) => console.error(e)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment