top*_*tts 1 c# firefox selenium geckodriver
我无法让Selenium与c#上的Firefox驱动程序一起使用。Chrome可以完美运行,但Firefox无法运行。
使用方法:
我已经在Windows中设置了path变量。
GeckoDriver已安装在源代码的Bin文件夹中。
Firefoxdriverservice不存在,因此无法使用该命令。
我收到的错误是“ 引发异常:System.ComponentModel.Win32Exception:系统找不到指定的文件 ”
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using System.Windows.Forms;
namespace BeatRecaptcha
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
IWebDriver driver = new FirefoxDriver();
driver.Manage().Window.Maximize();
//Go to Google
driver.Navigate().GoToUrl("www.google.co.uk");
}
}
Run Code Online (Sandbox Code Playgroud)
}
不知道您是否最近升级到最新版本的Selenium,但是由于Selenium 3.0,您还需要根据系统配置从下面的URL下载geckodriver.exe。
https://github.com/mozilla/geckodriver/releases
然后,您可以尝试如下操作:
//Give the path of the geckodriver.exe
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(@"C:\Users\abcd\Downloads\geckodriver-v0.13.0-win64","geckodriver.exe")
//Give the path of the Firefox Browser
service.FirefoxBinaryPath = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
IWebDriver driver = new FirefoxDriver(service);
driver.Navigate().GoToUrl("https://www.google.com");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6766 次 |
| 最近记录: |