2013-12-15 73 views
4

我嘗試請點擊此鏈接:http://www.seleniumhq.org/docs/03_webdriver.jsp如何啓動硒與Firefox司機

SetUpTest

protected IWebDriver driver; 
protected ISelenium selenium; 
[SetUp] 
public void SetupTest() 
{ 
    driver = new FirefoxDriver(); 
    selenium = new DefaultSelenium(
     "localhost", 
     4444, 
     "*chrome", 
     "http://localhost"); 
    selenium.Start(); 
    verificationErrors = new StringBuilder(); 
} 

當這條線driver = new FirefoxDriver();執行,我有這樣的錯誤:

Additional information: Cannot find a file named '***[Link to my project]\webdriver.xpi' or an embedded resource with the id 'WebDriver.FirefoxExt.zip'. 

當我將其更改爲driver = new ChromeDriver();時,它會打開firefox,但它無法找到元素,儘管元素已經是ren DER。

如何使硒與Firefox的作​​品?

+0

您的代碼/框架託管在GitHub上或某處我可以看到您如何設置它? –

+1

與您之前的問題類似:停止混合Selenium RC和WebDriver。你應該退後一步並閱讀文檔。那裏的文檔詳細解釋了**你應該如何讓Selenium工作。 – Arran

回答

0

如果您是使用C#,這似乎已添加的硒兩者結合的.NET和Firefox驅動

我下面這個教程https://docs.microsoft.com/en-us/vsts/build-release/test/continuous-test-selenium#create-the-test-project的NuGet包。它要求以添加所有這些包

After the project is created, you must add the Selenium and browser driver references used by the browser to execute the tests. Open the shortcut menu for the Unit Test project and choose Manage NuGet Packages. Add the following packages to your project:

Selenium.WebDriver

Selenium.WebDriver.ChromeDriver

Selenium.WebDriver.IEDriver

Selenium.Firefox.WebDriver

Selenium.WebDriver.PhantomJS.Xplatform

這是錯誤。如果您使用Firefox驅動程序,則只需要Selenium.WebDriver(也可能爲Selenium.Support)和Selenium.Firefox.WebDriver。您不需要Selenium.WebDriver.PhantomJS.Xplatform這會將錯誤的WebDriver.dll添加到您的項目中,並且測試運行會抱怨丟失.json.xpi文件。