Skip to content

Instantly share code, notes, and snippets.

@dineshsprabu
Created February 16, 2016 04:50
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 dineshsprabu/39919a2f0efd9ff1f3c4 to your computer and use it in GitHub Desktop.
Save dineshsprabu/39919a2f0efd9ff1f3c4 to your computer and use it in GitHub Desktop.
[Selenium][Phantomjs] How to use PhantomJS web driver server with NodeJS?
/*
Bring up the selenium webdriver server using below command
phantomjs --proxy=104.131.57.228:8090 --proxy-type=http --webdriver=8543
The value in --webdriver is the port binded on wd server
*/
var webdriver = require('selenium-webdriver');
var browser = webdriver.Capabilities.phantomjs();
browser.set('phantomjs.page.settings.userAgent', "Mozilla");
var driver = new webdriver.Builder()
.usingServer('http://localhost:8543/wd/hub')
.withCapabilities(browser)
.build();
var url = "https://httpbin.org/ip";
driver.get(url).then(function(){
driver.getPageSource()
.then(function(body){
console.log(body);
});
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment