2016-09-29 34 views
0

我是新使用Java,硒恩的webdriver的硒3 Firefox是不會給定的URL

我使用:硒3 beta3版,Java的jdk1.8.0_101和firefox 48.01 另外我用Geckodriver因爲這是使用sel3所需要的。

我試圖打開一個URL。打開瀏覽器正在工作。 我使用的代碼如下。

package AutomatedScripts; 
import org.openqa.selenium.WebDriver; // driver for Webdriver 
import org.openqa.selenium.firefox.FirefoxDriver; //driver for Firefox 

public class GoogleSearchOneTime { 

    public static void main(String[] agrs) { 
     System.setProperty("webdriver.firefox.marionette","C:\\selenium-3.0.0\\geckodriver\\geckodriver.exe"); 
     // Launch a firefox browser 
     WebDriver driver = new FirefoxDriver(); 

     // go to Google.com 
     driver.get("http://www.google.com"); 
     // go to google.com 
     // driver.navigate().to("http://www.google.com");   

     //Enter search terms 
     //driver.findElement(By.id("lst-ib")).clear(); 
     //driver.findElement(By.id("lst-ib")).sendKeys("Google"); 

     //Click on the searh button 
     //driver.findElement(By.name("btnG")).click(); 
     //check page title contacts the search term 


    } 

} 

回答

2

更換你System.setProperty如下

System.setProperty("webdriver.gecko.driver", "C:\\selenium-3.0.0\\geckodriver\\geckodriver.exe"); 

下面一個例子鏈接,你可以參考Launching firefox browser using Geckodriver