試圖獲得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上下文)
最好不要用在λ當地司機,你最好通過保持外部硒網格,然後在你的腳本 –