使用Selenium WebDriver在AWS Lambda上运行Chrome时出错

时间:2019-06-13 15:38:35

标签: amazon-web-services selenium-webdriver aws-lambda specflow xunit

I am deploying my code on AWS LAMBDA which run chrome and executes the script but I'm getting below error while running chrome on aws lambda using selenium webdriver c#

错误代码:
在端口33557上启动ChromeDriver 2.40.565383(76257d1ab79276b2d53ee976b2c3e3b9f335cde7)     仅允许本地连接。 [1560439252.325] [SEVERE]:CreatePlatformSocket()返回错误,错误号97:协议不支持的地址族(97) 例外:30秒后,对远程WebDriver服务器的URL http://localhost:33557/session的HTTP请求超时。 在OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo) 在OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute) 在OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute) 在OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute,Dictionary`2 parameters) 在OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities wantedCapabilities) 在OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor,ICapabilities requiredCapabilities) 在OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService服务,ChromeOptions选项,TimeSpan命令超时) 在\ src \ MyFunction \ Function.cs中的MyFunction.Function.ChromeSettings()处:第67行Function方法中驱动程序的值... 对象引用未设置为对象的实例。:\ src \ MyFunction \ Function.cs:line 43中MyFunction.Function.FunctionHandler(ILambdaContext context)处的NullReferenceException END RequestId:46528df6-0282-459a-89ff-8b078e00edc6 REPORT RequestId:46528df6-0282-459a-89ff-8b078e00edc6持续时间:30445.86 ms计费持续时间:30500 ms内存大小:2432 MB使用的最大内存:92 MB

I tried using almost all latest versions of chrome binaries with chromedrivers

Console.Write("Inside ChromeSettings()...\n");
            //var service = ChromeDriverService.CreateDefaultService();
            //service.HideCommandPromptWindow = true;
            ChromePerformanceLoggingPreferences logPrefs = new ChromePerformanceLoggingPreferences();
            logPrefs.AddTracingCategory(LogType.Profiler);
            ChromeOptions options = SetChromeOption();
            options.SetLoggingPreference(LogType.Browser, LogLevel.All);
            Console.Write("After ChromeSettings()...\n");
            ChromeDriver cDriver = null;
            try
            {
                Console.Write("Before creating driver...\n"+ Environment.CurrentDirectory+" \n");
                ChromeDriverService service = ChromeDriverService.CreateDefaultService("/var/task", "chromedriver");
                cDriver = new ChromeDriver(service, options, TimeSpan.FromSeconds(30));
                Console.Write("capabilities: " + cDriver.Capabilities + "\n");
                cDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(40);
                cDriver.Manage().Window.Maximize();
                Console.Write("Chrome driver capabilities: " + cDriver.Capabilities + "\n");
                return cDriver;
            }
            catch (Exception ex)
            {
                Console.Write("Exception: " + ex.Message + "\n");
                Console.Write(ex.StackTrace);
                return null;
            }



Expected - result should be if I pass the site url it should return the title of the site using  driver.Title;

Actual - CreatePlatformSocket() returned an error, errno=97: Address family not supported by protocol (97)  15:21:22 Exception: The HTTP request to the remote WebDriver server for URL http://localhost:33557/session timed out after 30 seconds.

0 个答案:

没有答案