Build the java environment of selenium phantomjs browser
Build × × × face browser by java selenium
1. Http://phantomjs.org/
Download phantomjs for windows
two。 After decompression, there will be exe files in the bin directory.
3. Test the code:
Copy the code
Package se
Import org.openqa.selenium.WebDriver
Import org.openqa.selenium.firefox.FirefoxDriver
Import org.openqa.selenium.phantomjs.PhantomJSDriver
Public class test {
Public static void main (String [] args) {/ / TODO Auto-generated method stub// System.setProperty ("webdriver.gecko.driver", "C:\ Program Files (x86)\\ Mozilla Firefox\\ geckodriver.exe"); System.setProperty ("phantomjs.binary.path", "C:\ phantomjs-2.1.1-windows\\ bin\\ phantomjs.exe"); / / WebDriver driver = new FirefoxDriver (); WebDriver driver = new PhantomJSDriver () Driver.get ("http://www.baidu.com"); System.out.println (driver.getCurrentUrl ());}
}
4.url prints successfully
5.