Skip to content

Instantly share code, notes, and snippets.

@SergeyAvd
Created February 6, 2017 21:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SergeyAvd/3466c9e2330b3a89e7d00a19ccd59f57 to your computer and use it in GitHub Desktop.
Save SergeyAvd/3466c9e2330b3a89e7d00a19ccd59f57 to your computer and use it in GitHub Desktop.
Basic example modified to use an already running Chrome browser
// google_search.js
var chromeDriver = require('chromedriver'), // Auto install ChromeDriver
webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until;
var chrome = require("selenium-webdriver/chrome");
var options = new chrome.Options();
options.options_["debuggerAddress"] = "127.0.0.1:6813";
var driver = new webdriver.Builder()
.forBrowser('chrome')
.setChromeOptions(options)
.build();
function start() {
driver.get('http://www.google.com/ncr');
driver.findElement(By.name('q')).sendKeys('webdriver');
driver.findElement(By.name('btnG')).click();
driver.wait(until.titleIs('webdriver - Google Search'), 1000);
setTimeout(function () {console.log('HI');}, 10000);
}
process.on('SIGTERM', function shutdown() {
driver.quit();
});
start();
@SergeyAvd
Copy link
Author

To test launch Chrome before the script like this:
chrome.exe --remote-debugging-port=6813

@Ankit123P
Copy link

Hi, Can you please let me know how to achieve this with WebDriverIO? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment