C# Selenium WebDriver没有';不能在IIS 10上启动,但如果应用程序托管在进程中,则可以正常工作
我有一个C# Selenium WebDriver没有';不能在IIS 10上启动,但如果应用程序托管在进程中,则可以正常工作,c#,selenium,asp.net-core-mvc,C#,Selenium,Asp.net Core Mvc,我有一个ASP.NET MVC CORE 3.0应用程序,我的要求是在IIS 10上运行Selenium。当我托管我的应用程序InProcess时,它会工作,只要我切换到IIS它就会停止工作(没有任何错误消息,也不管应用程序池配置文件如何)。我有以下代码,但我相信这些代码与这个特定问题无关 public void OpenOrReuseDriver(bool headlessMode = false, bool reuse = true) { if (!_driver.IsClosed(
ASP.NET MVC CORE 3.0
应用程序,我的要求是在IIS 10
上运行Selenium
。当我托管我的应用程序InProcess
时,它会工作,只要我切换到IIS
它就会停止工作(没有任何错误消息,也不管应用程序池配置文件如何)。我有以下代码,但我相信这些代码与这个特定问题无关
public void OpenOrReuseDriver(bool headlessMode = false, bool reuse = true)
{
if (!_driver.IsClosed()) return;
if (reuse && _drivers.Any() && _drivers.Last().IsOpen())
_driver = _drivers.Last();
else
{
var chromeService = ChromeDriverService.CreateDefaultService($@"{AppDomain.CurrentDomain.BaseDirectory}"); // Directory.GetCurrentDirectory() // AppDomain.CurrentDomain.BaseDirectory // Directory.GetCurrentDirectory()}\wwwroot
var chromeOptions = new ChromeOptions
{
BinaryLocation = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
};
if (headlessMode)
{
chromeOptions.AddArguments(new List<string>
{
"--silent-launch",
"--no-startup-window",
"no-sandbox",
"headless"
});
chromeService.HideCommandPromptWindow = true;
}
_driver = new ChromeDriver(chromeService, chromeOptions);
var size = new Size(1240, 720);
_driver.Manage().Window.Size = size;
_driver.Manage().Window.Position = PointUtils.CenteredWindowTopLeft(size).ToDrawingPoint();
_driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(60);
_driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);
_drivers.Add(_driver);
}
}
public void OpenOrReuseDriver(bool headlessode=false,bool reuse=true)
{
如果(!\u driver.IsClosed())返回;
if(重用&&&u驱动程序.Any()&&&u驱动程序.Last().IsOpen())
_driver=_drivers.Last();
其他的
{
var chromeService=ChromeDriverService.CreateDefaultService($@“{AppDomain.CurrentDomain.BaseDirectory}”);//目录.GetCurrentDirectory()//AppDomain.CurrentDomain.BaseDirectory//目录.GetCurrentDirectory()}\wwwroot
var chromeOptions=新的chromeOptions
{
BinaryLocation=@“C:\ProgramFiles(x86)\Google\Chrome\Application\Chrome.exe”
};
if(标题模式)
{
chromeOptions.AddArguments(新列表
{
“--无声发射”,
“--无启动窗口”,
“没有沙箱”,
“无头”
});
chromeService.HideCommandPromptWindow=true;
}
_驱动程序=新的色度驱动程序(色度服务、色度选项);
变量大小=新大小(1240720);
_driver.Manage().Window.Size=Size;
_driver.Manage().Window.Position=PointUtils.CenteredWindowTopLeft(大小).ToDrawingPoint();
_driver.Manage().Timeouts().PageLoad=TimeSpan.FromSeconds(60);
_driver.Manage().Timeouts().ImplicitWait=TimeSpan.FromSeconds(30);
_驱动程序。添加(_驱动程序);
}
}
我想知道将使
Selenium
与IIS
协同工作的步骤,一旦切换到IIS
它停止工作,错误消息可能会有所帮助。但我怀疑这是因为IIS应用程序池是在受限用户配置文件下运行的,而standalone将使用当前用户配置文件运行。没有错误消息,并且无论配置文件如何,都会发生这种情况。我猜您需要挂接调试器并查看它为何会中断…Selenium本身没有错误,没有权限问题,调试会话也完全没有异常。如果不是这样的话,我不会发帖。