Created
February 16, 2016 04:50
-
-
Save dineshsprabu/39919a2f0efd9ff1f3c4 to your computer and use it in GitHub Desktop.
[Selenium][Phantomjs] How to use PhantomJS web driver server with NodeJS?
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
/* | |
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