【发布时间】:2017-10-05 10:52:04
【问题描述】:
web api core 2.0 项目看不到 geckodriver.exe 我该如何解决?!
我创建了一个 asp.net core 2.0 web api 项目。 我将 geckodriver.exe 放到项目目录中,我将“复制到输出目录”更改为“始终复制”。
这是我的控制器:
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
namespace WebApplication1.Controllers
{
[Route("api/[controller]")]
public class ValuesController : Controller
{
// GET api/values
[HttpGet]
public IEnumerable<string> Get()
{
if (!System.IO.File.Exists("geckodriver.exe"))
{
throw new Exception("error");
}
using (IWebDriver driver = new FirefoxDriver())
{
driver.Navigate().GoToUrl("http://gooogle.com");
}
return new string[] { "value1", "value2" };
}
}
}
当我开始我的项目时,我收到异常消息
OpenQA.Selenium.DriverServiceNotFoundException: 'geckodriver.exe 文件不存在于当前目录或 PATH 环境变量的目录中。驱动可以在https://github.com/mozilla/geckodriver/releases下载。'
我想知道为什么 .net framework mvc 应用程序与相同的代码运行良好!
我的问题是:如何解决我的问题?我在谷歌上找不到解决方案
【问题讨论】:
标签: c# asp.net selenium automated-tests geckodriver