Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Build the java environment of selenium phantomjs browser

Shulou Source: shulou.com Published: 2022-06-03 04:47:54 11月25日 Update

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.

Tags: Code browser browse success file directory test environment Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB vpn Redmi NVidia OPPO Reno