![](/img/trans.png)
[英]Programmatically Installing IIS Windows Server 2016 using C# or WixToolset
[英]C# chrome driver only opening as background process on IIS / Windows Server 2016
我在带有 IIS 的 Windows Server 2016 上运行 chromedriver,我安装了我的测试项目并使用 MVC5 API 调用它。 一切看起来都很好,但 chromedriver 和 chrome.exe 似乎只作为后台进程打开。
相同的代码在本地打开这些很好,我也没有使用任何驱动程序标志进行无头浏览。 如果我返回驱动器页面源,我可以看到 chromedriver 去谷歌并在我的 API 中返回了正确的 html。
它只是不适用于谷歌或我们的应用程序的正常/非无头测试。
var driver = x.StartWebDriver();
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl("http://www.google.com");
return driver.PageSource;
有什么想法吗?
我遇到了同样的问题,这就是我解决这个问题的方法:
打开命令提示符并导航到您的 ChromeDriver 位置。
执行 chromedriver.exe,您将看到如下消息。 图像在这里
在上图中,您可以看到 chrome 驱动程序正在侦听端口 9515。
现在改变你的代码如下,重建并调用你的api来执行你的测试。
ChromeOptions options = new ChromeOptions();
//在这里设置你的chromeoptions
Uri uri = new Uri(" http://localhost :**9515 ");
_driver = new RemoteWebDriver(uri, options);
打开chrome驱动程序并记下端口号(例如:5353)
在Java中:
System.setProperty(chromeDriverName, chromeDriverLocation);
ChromeOptions options = new ChromeOptions();
URL uri = new URL(chromeDriverPort);//http://localhost:5353
WebDriver 驱动程序 = new RemoteWebDriver(uri, options);
您的问题在服务器中得到解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.