Internet Explorer 中的 Selen 测试总是超时?

发布于 2024-09-12 00:35:56 字数 572 浏览 6 评论 0原文

我正在尝试通过 Selenium-RC/PHPUnit 在 Internet Explorer 中运行基本测试,它总是返回

# phpunit c:\googletest.php
PHPUnit 3.4.15 by Sebastian Bergmann.

E

Time: 35 seconds, Memory: 4.75Mb

There was 1 error:

1) Example::testMyTestCase
PHPUnit_Framework_Exception: Response from Selenium RC server for testComplete()
.
Timed out after 30000ms.


C:\googletest.php:17

FAILURES!
Tests: 1, Assertions: 0, Errors: 1.

Paul@PAUL-TS-LAPTOP C:\xampp
#

命令历史记录中的最后一个命令是 waitForPageToLoad(30000)。同样的测试在 Firefox 中运行良好并完成。如何在 Internet Explorer 中运行并完成此测试?

谢谢

I'm trying to run a basic test in Internet Explorer via Selenium-RC/PHPUnit, and it always returns with

# phpunit c:\googletest.php
PHPUnit 3.4.15 by Sebastian Bergmann.

E

Time: 35 seconds, Memory: 4.75Mb

There was 1 error:

1) Example::testMyTestCase
PHPUnit_Framework_Exception: Response from Selenium RC server for testComplete()
.
Timed out after 30000ms.


C:\googletest.php:17

FAILURES!
Tests: 1, Assertions: 0, Errors: 1.

Paul@PAUL-TS-LAPTOP C:\xampp
#

The last command in command history is waitForPageToLoad(30000). The same test runs fine and completes in firefox. How can I get this test to run and complete in internet explorer?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

握住我的手 2024-09-19 00:35:56

selenium 中存在一个未解决的错误,导致 waitForPageToLoad 有时在 IE 上超时。

http://jira.openqa.org/browse/SRC-552

它被标记为发生在 IE6 上,但我至少在 IE9 中遇到同样的错误。

解决方法是等待正在加载的页面上的特定 DOM 元素,而不是使用 waitForPageToLoad。例如:waitForVisible('css=#header')

There's an open bug in selenium that causes waitForPageToLoad to sometimes timeout on IE.

http://jira.openqa.org/browse/SRC-552

It's marked as occurring on IE6, but I'm experiencing the same error in at least IE9.

A workaround is to wait for e.g. a specific DOM-element on the page that is loading instead of using waitForPageToLoad. For example: waitForVisible('css=#header')

昇り龍 2024-09-19 00:35:56

尝试进入“Internet 选项”并在“安全”选项卡下关闭“保护模式”。您可能还想降低 Internet 区域的安全级别。

Try going into Internet Options and turn off Protected mode under the security tab. You may also want to decrease the security level for the Internet zone.

缪败 2024-09-19 00:35:56

我已经关闭了保护模式,看起来它有帮助。

I've turned off protected mode and looks like it helped.

你怎么这么可爱啊 2024-09-19 00:35:56

如果可以自定义客户端驱动程序,这里有Python实现供您参考:

def open(self):
    timeout = self.get_eval('this.defaultTimeout')
    self.set_timeout(0)
    self.do_command("open", [url,ignoreResponseCode])
    self.set_timeout(timeout)
    self.wait_for_page_to_load(timeout)

def wait_for_page_to_load(self,timeout):
    # self.do_command("waitForPageToLoad", [timeout,])
    import time
    end = time.time() + int(float(timeout) / 1000)
    while time.time() < end:
        if self.get_eval('window.document.readyState') == 'complete': return
        time.sleep(2)
    raise Exception('Time out after %sms' % timeout)

我只是使用DOM属性document.readyState来确定页面是否完全加载。

IE 9+ 即使页面已满也会间歇性抛出超时错误已加载,了解更多详细信息。

If it is acceptable to customize the client driver, here is the Python implementation for your refernece:

def open(self):
    timeout = self.get_eval('this.defaultTimeout')
    self.set_timeout(0)
    self.do_command("open", [url,ignoreResponseCode])
    self.set_timeout(timeout)
    self.wait_for_page_to_load(timeout)

def wait_for_page_to_load(self,timeout):
    # self.do_command("waitForPageToLoad", [timeout,])
    import time
    end = time.time() + int(float(timeout) / 1000)
    while time.time() < end:
        if self.get_eval('window.document.readyState') == 'complete': return
        time.sleep(2)
    raise Exception('Time out after %sms' % timeout)

I just use DOM attribute document.readyState to determine if the page is fully loaded.

IE 9+ intermittently throws a timeout error even the page is fully loaded, for more details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文