2011-10-12 123 views
0

我真的很陌生,所以对我来说很简单。我有Seleneium与Pear,PHPUnit和Sauce Labs类SauceOnDemandTestCase.php一起工作。我可以运行测试,并做了一个简单的就好了。但是现在我正在做更复杂的测试并且不断收到超时消息。我查看了StackO上的错误,其他人也在使用IE。现在我的测试使用Firefox,所以我不知道为什么会这样。其他职位是在这里:硒RC/PHPUnit测试总是超时?

PHPUnit_Framework_Exception: Could not connect to the Selenium RC server when I run with Hudson

我试图改变我的等待功能waitForElement或waitForVisible但无济于事,它仍然无法与一个错误。这是我的XML日志文件输出,如果这对你有用:

<?xml version="1.0" encoding="UTF-8"?> 
<testsuites> 
    <testsuite name="ExampleTest" file="C:\websites\saucelabs\ExampleTest.php" tests="1" assertions="0" failures="0" errors="1" time="44.717224"> 
    <testsuite name="ExampleTest: Testing Selenium 1 in PHP at Sauce (FF 7)" tests="1" assertions="0" failures="0" errors="1" time="44.717224"> 
     <testcase name="test_example" class="ExampleTest" file="C:\websites\saucelabs\ExampleTest.php" line="23" assertions="0" time="44.717224"> 
     <error type="PHPUnit_Framework_Exception">ExampleTest::test_example with browser firefox 7 Windows 2003 
PHPUnit_Framework_Exception: 
Response from Selenium RC server for open(/Home). 
Timed out after 30000ms. 

Current Browser URL: http://www.vehicleportal.co.uk/Home 
Sauce Labs Job: https://saucelabs.com/jobs/8b202faaa055e213233637610fcd4448 


</error> 
     </testcase> 
    </testsuite> 
    </testsuite> 
</testsuites> 

我的脚本类如下所示:

<?php 

date_default_timezone_set('Europe/London'); 

require_once 'PHPUnit/Extensions/SeleniumTestCase/SauceOnDemandTestCase.php'; 
require_once 'Log.php'; 

class ExampleTest extends PHPUnit_Extensions_SeleniumTestCase_SauceOnDemandTestCase { 
    public static $browsers = array(
      array(
      'name' => 'Testing Selenium 1 in PHP at Sauce (FF 7)', 
      'browser' => 'firefox', 
      'os' => 'Windows 2003', 
      'browserVersion' => '7', 
     ) 
    ); 

    function setUp() { 
     $this->setBrowserUrl('http://www.vehicleportal.co.uk'); 

    } 

    function test_example() { 
     //$this->open('/'); 
     //$this->assertTitle('Cross browser testing with Selenium - Sauce Labs'); 

     //$file = Log::factory('file', 'out.log', 'TEST'); 
     //$file->log("info"); 

     $this->open("/Home"); 
     $this->click("hlLogin1"); 
     $this->waitForVisible('h1'); 
     $this->type("txtLoginEmailAddress", "[email protected]"); 
     $this->type("txtLoginPassword", "password"); 
     $this->click("btnLogin"); 
     $this->waitForVisible('h1'); 
     $this->verifyText("id=hlVehicleLookup", "Vehicle Lookup"); 
     $this->click("css=img[alt=Home]"); 
     $this->waitForVisible('h1'); 
     $this->click("link=Logout"); 
     $this->waitForVisible('h1'); 
    } 
} 

给予一定的背景我要创建我的硒IDE或SauceLabs建设者脚本然后转换它,以便从Selenium IDE中获取步骤。

我有第二个小问题,我希望更好地理解。我不断收到:

“通知:未定义指数:家在C:\ PHP \ PEAR \ PHPUnit的\扩展\ SeleniumTestCase \ SauceOnDemandTestCase.php线149”

149从该文件专线: $ yml_path = realpath($ _ SERVER ['HOME'])。 '/.sauce/ondemand.yml';

班SauceLabs:https://github.com/saucelabs/phpunit-selenium-sauceondemand/blob/master/PHPUnit/Extensions/SeleniumTestCase/SauceOnDemandTestCase.php

我可以删除提及这一点,但为什么会出现?毕竟$ _SERVER ['home']不是$ _SERVER数组的PHP。

UPDATE

我们有一个理论超时被SL没有使用真正的浏览器造成的。我完全删除了所有验证步骤,但仍然发生超时。

回答

1

我认为这是由于尝试运行超时太小的测试引起的。我增加了超时时间,这很好。

除了一个浏览器外,所有浏览器都可以。报告的错误是:

“Selenium RC server for waitForPageToLoad(30000)的响应。在30000ms后超时“

我看不出增加超时期限的点,因为它使用相同的浏览器版本,因此它必须与Sauce有关,最后我尝试增加时间限制为90秒(90000)毫秒,我做了一个理论,由于使用Sauce的测试时间延长了,这必须导致脚本在这个浏览器上超时,无论如何,解决方案是按照建议增加超时通过

错误消息我在这里写一下吧:

TestIgniter Blog Post

+1

请包括您的文章摘录给你的答案一些上下文。 – BoltClock

1

Firefox窗口是否打开过?例如,如果你用I.E来配置它,你会得到同样的错误吗?

因为这可能与Selenium配置为使用Firefox 3.6版本(距离今天的7.0.1很远)有关,所以你可以改变它。 Here is a guide这将帮助你改变这一点。

一两件事,尝试()函数将在设置这一行:

$this->setBrowser("*firefox"); 

希望这有助于!保持我的发布。

+0

谢谢你的尝试。我会在某个时候看看这个指南。我认为Sauce Labs自己的浏览器名称与Selenium RC中的浏览器名称不同,因此可能不适用于* firefox。 – Adamantus