2013-12-15 38 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文件。