2010-07-30 125 views
3

我试图通过Selenium-RC/PHPUnit的运行在Internet Explorer中一个基本的测试,它总是与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. 

[email protected] C:\xampp 
# 

返回命令历史记录的最后一个命令是waitForPageToLoad(30000)。相同的测试运行良好,并在Firefox中完成。我怎样才能让这个测试在Internet Explorer中运行和完成?

谢谢

+0

我们可以看看你的测试是什么样子吗? – AutomatedTester 2010-08-02 07:25:30

+0

如果您在Vista上使用IE7或更高版本,请尝试将测试下的网站添加到受信任的网站上 – 2010-08-02 13:21:25

回答

3

硒中有一个开放的错误,导致waitForPageToLoad有时在IE上超时。

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

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

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

1

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

+0

尚未有机会尝试此操作,因为我已经提供了另一个任务,因为我问了这个问题。当我尝试过时会更新。谢谢 – psynnott 2010-08-20 19:55:41

1

我已关闭保护模式,看起来像它的帮助。

1

如果可以接受定制客户端驱动程序,这里是你的refernece 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+ intermittently throws a timeout error even the page is fully loaded,了解更多详情。

相关问题