Sea*_*anS 26 c# firefox selenium selenium-firefoxdriver selenium-webdriver
看到很多关于Selenium 2.53.1和Firefox 47.0.1的问题,但没有关于Selenium 3 Beta版本的问题.我正在尝试使用新的gecko/marionette Firefox webdrivers,但即使我有驱动程序位置; 我的环境路径,Firefox在程序中安装文件夹,并在系统环境中给出驱动器位置,它仍然无法正常工作.
错误:
geckodriver.exe不存在于当前目录或PATH环境变量的目录中.该驱动程序可以从https://github.com/mozilla/geckodriver/releases下载.
使用:
示例代码1
using OpenQA.Selenium.Firefox;
public static class FirefoxInitialise
{
public static IWebDriver Driver {get; set;}
Driver = new FirefoxDriver();
}
Run Code Online (Sandbox Code Playgroud)
还尝试了以下内容:
using OpenQA.Selenium.Firefox;
public static class FirefoxInitialise
{
public static IWebDriver Driver {get; set;}
FirefoxDriverServices service = FirefoxDriverService.CreateDefaultService();
service.FirefoxBinaryPath = @"C:\Program Files\Mozilla Firefox\firefox.exe";
FirefoxOptions options = new FirefoxOptions();
TimeSpan time = TimeSpan.FromSeconds(10);
Driver = new FirefoxDriver(service, options, time);
}
Run Code Online (Sandbox Code Playgroud)
任何有关代码仍然无法检测到此驱动程序的帮助或见解将非常感激.
小智 26
尝试将geckodriver.exe放在您的路径中:C:\ Users\YourName\Documents\Visual Studio 2013\Projects\seleniump\seleniump\bin\Debug
你可以在这个链接上找到geckodriver.exe:
https://github.com/mozilla/geckodriver/releases
Han*_*onn 21
安装Selenium.Firefox.Webdriver NuGet包.
这会将geckodriver.exe复制到bin文件夹.
小智 9
此解决方案可以帮助您解决问题:(虽然它确实帮助了我)
public class TestResult {
private IWebDriver driver;
private StringBuilder verificationErrors;
private string baseURL;
private bool acceptNextAlert = true;
[TestInitialize]
public void SetupTest() {
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(@"C:\geckodriver", "geckodriver.exe");
service.Port = 64444;
service.FirefoxBinaryPath = @"C:\Program Files (x86)\Firefox Developer Edition\firefox.exe";
driver = new FirefoxDriver(service);
baseURL = "http://localhost:49539";
verificationErrors = new StringBuilder();
}
}
Run Code Online (Sandbox Code Playgroud)
参考
| 归档时间: |
|
| 查看次数: |
46946 次 |
| 最近记录: |