簡體   English   中英

Firefox的Firefox驅動程序或Chrome驅動程序出現問題

[英]Having issues with firefox driver or chrome driver for selenium

例如,當我將Chrome放到命令提示符提示符下時,它為我提供了路徑-/ Applications / Google \\ Chrome.app

我設置

System.setProperty(“ webdriver.chrome.driver”,“ /Applications/Google/Chrome.app”); WebDriver驅動程序=新的C​​hromeDriver();
driver.get(“ http://www.google.com ”);

但它不起作用,與Firefox相同。 我使用了很多已經給出的建議,但似乎都沒有用。 有人可以讓我知道是否要添加一些內容嗎?

為什么使用“ /Applications/Google/Chrome.app”。 您只需要提供驅動程序的路徑,而不需要提供瀏覽器的路徑。 以下是Firefox的代碼,但您需要下載並配置GeckoDriver(適用於FF和Selenium 3.x的最新版本)

public class FirefoxTest {

@Test
public void FirefoxTest_Test1() {
    System.setProperty("webdriver.gecko.driver","D:\\Firefox\\geckodriver.exe");
    FirefoxDriver driver = new FirefoxDriver();
    driver.get("http://www.google.com");
}
}

檢查此鏈接為完整的詳細信息下載和使用Firefox Geckodriver的設置- http://automationtestinghub.com/selenium-3-0-launch-firefox-with-geckodriver/

使用chrome驅動程序最簡單的方法是..下載並將驅動程序放入項目的bin文件夾中。 無需設置驅動程序位置的路徑

對於Chrome:需要從http://chromedriver.storage.googleapis.com/index.html?path=2.24/下載最新的Chrome驅動程序,並提及chomedriver.exe之前的本地系統路徑。

System.setProperty("webdriver.chrome.driver","G:\\ravik\\Ravi-Training\\Selenium\\Drivers\\cd\\chromedriver.exe");
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    ChromeDriver d1 = new ChromeDriver(capabilities);

對於FF:如果您的firefox版本是最新的(46.0或更高版本),則用戶geckodriver以及硒2.53.0 jar文件。 下載geckodriver表格https://github.com/mozilla/geckodriver/releases ,然后將其保存為本地系統中的“電線”。 提到本地系統路徑,直到電線。

System.setProperty("webdriver.gecko.driver", "G:\\ravik\\Ravi-Training\\Selenium\\Marionette for firefox\\wires.exe");
    WebDriver driver = new MarionetteDriver();

希望這會有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM