2014-12-09 57 views
-1

我的默認瀏覽器是Firefox。但是當我嘗試使用硒web驅動加載文件時,它會自動通過谷歌瀏覽器加載。我如何將其更改爲Firefox? Eclipse首選項也已設置爲默認瀏覽器。使用selenium web驅動時在firefox中加載網站

package com.selenium.example; 

    import org.openqa.selenium.By; 
    import org.openqa.selenium.WebDriver; 
    import org.openqa.selenium.WebElement; 
    import org.openqa.selenium.firefox.FirefoxDriver; 

    public class ExampleSelenium { 

public static void main(String[] args) { 
    FirefoxDriver driver = new FirefoxDriver(); 
    driver.get("http://localhost:3030/fuseki.html"); 
}} 
+0

,如果你寫這FirefoxDriver驅動程序=新FirefoxDriver();那麼它必須在Firefox中打開。 – 2014-12-09 12:08:24

+0

@HelpingHands沒有發生。這是我的問題。它始終通過谷歌瀏覽器加載。我在谷歌瀏覽器中更改了代理設置。因此,不支持本地主機。所以我想通過Firefox加載localhost。 – Maduri 2014-12-09 12:13:49

+0

如果您使用其他網址,該怎麼辦?而不是本地主機?像google.com?是在Firefox中打開? – 2014-12-09 12:15:50

回答

1

以下方法請用戶得到URL:

driver.getUrl("Your host link"); 
相關問題