首页 文章

Selenium Webdriver C#Click工程然后在IE中超时

提问于
浏览
0

我正在使用clen bindings为selenium webdriver测试一个Web应用程序 . 测试点击了一些带有onclick功能的元素,如( onclick="window.location.href = 'google.com'" ) . 当涉及到最后一个元素时,它会单击它并加载下一个javascript图像查看应用程序页面 . 而不是测试结束页面保持在相同的位置打开60秒,直到它失败并出现错误:

在OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest请求)中的System.Net.HttpWebRequest.GetResponse()上的--WebException结果消息:OpenQA.Selenium.WebDriverException:对URL http:/的远程WebDriver服务器的HTTP请求/ localhost:27431 / session / fd102072-024b-4ccc-99af-4c8e609c027d / element / 0843e2a6-82ce-48ff-9ad2-2649585a43dc / 60秒后点击超时 . ----> System.Net.WebException:请求已中止:操作已超时 .

同样的测试适用于chrome和firefox . 该元素肯定会显示并单击 . 浏览器也正常进入页面,但由于某种原因超时 .

2 回答

  • 0

    这不是一个新问题 . 它已存在很长时间了 . 我一直在stackoverflowgoogle group阅读有关此问题的内容 . 尽管这个问题似乎是独一无二的(因为我已经使用了webdriver .net绑定大约两年而且从未遇到过这个问题)但IEDriver服务器的作者有一个坚实的explanation为什么会这样 . 很多人建议增加隐性等待可能有所帮助,即使我怀疑会这样做 . 阅读博客可以帮助您理解问题并找出问题所在 .

  • 0

    你需要做的是......:

    InternetExplorerDriverService driverService = InternetExplorerDriverService.CreateDefaultService();
                    //driverService.HideCommandPromptWindow = true;
                    driverService.LibraryExtractionPath = Environment.CurrentDirectory;
    
                    InternetExplorerOptions options = new InternetExplorerOptions();
                    options.EnableNativeEvents = true;
                    options.IgnoreZoomLevel = true;
                    options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
    
    
    
                    IWebDriver driver = new InternetExplorerDriver(driverService, options, TimeSpan.FromSeconds(180));
    

相关问题