共分三步:
1.selenium官网下载selenium-server-standalone.jar的最新版本
2.启动selenium-server:::::
java
-jar "selenium-server-standalone-2.2.0.jar"
-Dwebdriver.firefox.bin="C:\FirefoxCollection\Mozilla
Firefox 36.0\firefox.exe"
3.java代码初始化webdriver对象时:
DesiredCapabilities
capabilities = new DesiredCapabilities("firefox", "", Platform.ANY);
driver=new RemoteWebDriver(new URL("http://127.0.0.1:4444/wd/hub/"),capabilities);
Ps:如果是调用本地的浏览器的话,
System.setProperty("webdriver.firefox.bin",
"F:\\InstalledFiles\\firefox\\firefox.exe");
WebDriver
driver = new FirefoxDriver(); 即可
时间: 2024-10-12 06:26:18