【问题标题】:PhantomJSDriver Click element WebDriverException timeoutPhantomJSDriver 单击元素 WebDriverException 超时
【发布时间】:2014-01-14 02:06:41
【问题描述】:

我有一个输入元素,点击后会打开一个新的弹出窗口(用户可以在其中选择字段的值)。

标记:

<html>
<input type="text" id="myPopup" readonly="readonly" name="myPopup">
</html>

c#:

    var driver = new PhantomJSDriver(@"C:\PhantomJS");
    driver.Navigate().GoToUrl(@"http://username:password@localhost/myUrl.aspx");
    var popupField = driver.FindElementById("myPopup");
    popupField.Click();

(我在用于 Windows 身份验证的 URL 中传递凭据)

我得到一个 WebDriverException:

“对 URL ...element/:wdc:1389663237442/click 的远程 WebDriver 服务器的 HTTP 请求在 60 秒后超时。”

除了这个特定元素之外,我尝试的所有其他交互都有效。还尝试了 IE/Chrome 驱动程序,并且成功了。

有什么想法吗?

PhantomJS 1.9.2, C#/GhostDriver, Selenium Webdriver 2.39, 视窗 7 x64。 如果有任何其他信息可以提供,请告诉我。

【问题讨论】:

  • 我添加了标记。它适用于 IE/Chrome 驱动程序。
  • 我试过 wait.Until(ExpectedConditions.ElementIsVisible(By.Id("myPopup")) 和 Thread.Sleep(TimeSpan.FromMinutes(2)) 但我仍然收到超时错误。
  • Actions 或 JavaScript Click() 都不起作用 - 遇到相同的超时。我还尝试了 Actions ClickAndHold() > screenshot > Release() - 我可以看到在屏幕截图中点击了该元素,但在 Release 时我得到了超时。

标签: c# selenium phantomjs ghostdriver


【解决方案1】:

我遇到了类似的问题。正如您所描述的,测试在 FF 上有效,但在 PhantomJs 上超时。我正在测试的页面使用了很多我认为使用 XHR 的社交媒体插件。删除 PhantomJs 的大部分安全限制为我修复了它(见下文)。

service.IgnoreSslErrors = true;
service.WebSecurity = false; 
service.LocalToRemoteUrlAccess = true; 
service.DiskCache = true; // Dunno what this does but I thought it might help.
PhantomJSDriver driver = new PhantomJSDriver(service);

【讨论】:

    猜你喜欢
    • 2016-10-26
    • 1970-01-01
    • 2015-12-14
    • 1970-01-01
    • 2019-03-19
    • 1970-01-01
    • 1970-01-01
    • 2017-11-22
    相关资源
    最近更新 更多