2017-06-01 94 views
0

我是自動化測試中的新成員。 已經創建了一個簡單的程序在Firefox瀏覽器中打開URL。瀏覽器無法通過URL打開。 有人請幫忙。無法使用Java在Eclipse上使用給定的URL打開Firefox瀏覽器

package sanitytest; 

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

public class Adminlogin { 

    public static void main(String[]args){ 

     WebDriver driver = new FirefoxDriver(); 

     driver.get("http://www.gcrit.com/build3/admin/login.php"); 

    } 
} 

我使用的Firefox版本: - 47.0.1 蝕火星版: - 4.5.0 硒webdriver的版本: - 2.51

回答

3

對於Mozila的Firefox,直到46.x版本,它的最佳匹配是舊版瀏覽器,我們並不需要壁虎驅動程序。從版本47.x開始的Mozila Firefox自帶Marionette,它是Mozilla Gecko引擎的自動化驅動程序。它可以遠程控制UI或Gecko平臺的內部JavaScript,如Firefox。可以在這裏下載:https://github.com/mozilla/geckodriver/releases,需要硒3.x.

所以,要麼降級FF到46.x版本,或使用最新的硒與geckodriver +最新FF

+0

你剛纔提到'到版本47.x&OP是使用相同的FF 47.0.1。你爲什麼要把FF降級到版本46.x? – DebanjanB

+0

47不包括,更新的答案 –

+0

它幫了我很多。非常感謝你。 –

1

不幸的是硒的webdriver 2.51.0不與Firefox兼容47.0。處理Firefox瀏覽器的WebDriver組件(FirefoxDriver)將停止使用。

嘗試使用firefox 46.0.1。硒2.51

https://ftp.mozilla.org/pub/firefox/releases/

+0

它幫了我很多。非常感謝你。 –

+0

@anjitasinha歡迎你 – RNS

1

結合試試下面的代碼及其工作 包裝自動化;

import java.util.concurrent.TimeUnit 

enter code here 

import org.openqa.selenium.WebDriver; 

import org.openqa.selenium.firefox.FirefoxDriver; 

public class test { 
public static void main(String[] args) throws InterruptedException { 
//Object webdriver; 
System.setProperty("webdriver.gecko.driver", 
"C:\\Users\\user\\Downloads\\geckodriver-v0.17.0-win64/geckodriver.exe"); 

WebDriver driver = new FirefoxDriver(); 
driver.manage().window().maximize(); 
driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS); 
driver.get("https://www.easybooking.lk"); 
String i = driver.getCurrentUrl(); 
System.out.println(i); 
//driver.close(); 

} 

} 

如果它不工作http://www.seleniumhq.org/download/這裏下載java 3.4.0

然後在Eclipse中,右鍵點擊你的項目 - >屬性 - > Java構建路徑 - > liberies - >添加外部JAR ..

enter image description here

相關問題