2
我想运行一个简单的程序,但得到以下错误:PATH错误Visual Studio中硒的webdriver
An unhandled exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll
Additional information: Cannot find Firefox binary in PATH or default install locations. Make sure Firefox is installed. OS appears to be: Vista
代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
namespace selenium
{
class Program
{
static void Main(string[] args)
{
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.reuters.com");
driver.Manage().Window.Maximize();
IWebElement searchInput = driver.FindElement(By.XPath("//html/body/div[10]/div[3]/div/td[1]"));
searchInput.GetAttribute("value").ToString();
driver.Close();
}
}
}
我检查了环境变量,我有以下在路径中:
PATH=C:\Program Files\Mozilla Firefox\firefox.exe
我目前正在运行Windows 10,Visual Studio 2015和selenium Webdriver 2 .53.0
Windows'PATH'是一个目录列表,而不是文件名。请尝试将其改为“PATH = C:\ Program Files \ Mozilla Firefox”。 – dxiv
非常感谢。它像一个魅力工作 – user2434600
[在PATH中找不到firefox二进制文件的可能的重复。确保安装firefox](http://stackoverflow.com/questions/20950748/cannot-find-firefox-binary-in-path-make-sure-firefox-is-installed) – JeffC