试图获得AWS Lambda函数以在.NET Core上运行Selenium。这里是代码:如何使用.net核心在AWS Lambda中运行Selenium
public string FunctionHandler(ILambdaContext context)
{
context.Logger.LogLine("Entering function");
try
{
var driver = new InternetExplorerDriver();
context.Logger.LogLine("Navigating to URL");
driver.Navigate().GoToUrl("http://www.google.com/");
context.Logger.LogLine("Returning Done");
return "Done";
}
catch (Exception e)
{
context.Logger.LogLine("Oops: " + e);
return "Failed";
}
}
我在AWS控制台得到的错误是:
OpenQA.Selenium.WebDriverException:在OpenQA.Selenium.DriverService.Start上http://localhost:41663/ 无法启动驱动程序服务() 在OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(命令commandToExecute) 在OpenQA.Selenium.Remote.RemoteWebDriver.Execute(字符串driverCommandToExecute,Dictionary`2参数) 在OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities) 在OpenQA.Selenium.Remote.Re moteWebDriver..ctor(ICommandExecutor commandExecutor,ICapabilities desiredCapabilities) 在OpenQA.Selenium.IE.InternetExplorerDriver..ctor(InternetExplorerDriverService服务,InternetExplorerOptions选项,时间跨度的CommandTimeout) 在OpenQA.Selenium.IE.InternetExplorerDriver..ctor(InternetExplorerDriverService服务,InternetExplorerOptions选项) 在OpenQA.Selenium.IE.InternetExplorerDriver..ctor(InternetExplorerOptions选项) 在OpenQA.Selenium.IE.InternetExplorerDriver..ctor() 在InstagramMagic.Function.FunctionHandler(ILambdaContext上下文)
最好不要用在λ当地司机,你最好通过保持外部硒网格,然后在你的脚本 –