【发布时间】:2018-04-02 03:41:33
【问题描述】:
尝试获取 AWS Lambda 函数以在 .NET Core 上运行 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:无法在http://localhost:41663/ 上启动驱动程序服务 在 OpenQA.Selenium.DriverService.Start() 在 OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(命令 commandToExecute) 在 OpenQA.Selenium.Remote.RemoteWebDriver.Execute(字符串 driverCommandToExecute,Dictionary`2 参数) 在 OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities) 在 OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor,ICapabilities desiredCapabilities) 在 OpenQA.Selenium.IE.InternetExplorerDriver..ctor(InternetExplorerDriverService 服务,InternetExplorerOptions 选项,TimeSpan 命令超时) 在 OpenQA.Selenium.IE.InternetExplorerDriver..ctor(InternetExplorerDriverService 服务,InternetExplorerOptions 选项) 在 OpenQA.Selenium.IE.InternetExplorerDriver..ctor(InternetExplorerOptions 选项) 在 OpenQA.Selenium.IE.InternetExplorerDriver..ctor() 在 InstagramMagic.Function.FunctionHandler(ILambdaContext 上下文)
【问题讨论】:
-
最好不要在 Lambda 上使用本地驱动程序,最好保留一个外部 selenium 网格,然后在脚本中使用网格 url
标签: amazon-web-services selenium .net-core aws-lambda