![](/img/trans.png)
[英]Using Selenium, Python script to open Firefox, not going to URL provided
[英]Selenium 3 firefox is not going to the given url
我是Java使用Selenium和Webdriver的新手
我使用了:硒3 beta3,Java jdk1.8.0_101和firefox 48.01。此外,我還使用了Geckodriver,因為使用sel3需要它。
我正在嘗試打開一個網址。 打開瀏覽器正在工作。 我使用的代碼如下。
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
}
}
如下替換您的System.setProperty
System.setProperty("webdriver.gecko.driver", "C:\\selenium-3.0.0\\geckodriver\\geckodriver.exe");
這是一個示例鏈接,您可以參考使用Geckodriver啟動firefox瀏覽器
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.