Selenium RC / PHPUnit test always times out?

I'm really new to testing so go easy on me. I've got Seleneium working with Pear, PHPUnit, and Sauce Labs class SauceOnDemandTestCase.php. I can run tests and did a simple on just fine. But now I'm doing more complicated tests and keep receiving timeout messages. I've looked the error up on StackO and other people were getting it with IE. Now my test is using Firefox so I don't know why that would be. The other post is here:

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

I tried changing my wait functions to waitForElement or waitForVisible but to no avail, it still fails with one error. Here is my XML log file output if that's useful to you:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="ExampleTest" file="C:websitessaucelabsExampleTest.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:websitessaucelabsExampleTest.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>

My script class looks like this:

<?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", "user@volkswagen.co.uk");
        $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');
    }
}

To give some background I have to create my script in Selenium IDE or SauceLabs builder and then convert it so the steps are taken from Selenium IDE.

I have a second smaller problem which I'd like to understand better. I keep getting:

"Notice: Undefined index: HOME in c:phpPEARPHPUnitExtensionsSeleniumTestCaseSauceOnDemandTestCase.php on line 149"

Line 149 from that file: $yml_path = realpath($_SERVER['HOME']) . '/.sauce/ondemand.yml';

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

I could remove the reference to this but why is it there? Afterall $_SERVER['home'] is not PHP of the $_SERVER array.

UPDATE

We had a theory the timeout was caused by SL not using a real browser. I removed all of the verify steps completely but the timeout still occurs.


Does the firefox window ever open? If you configure this with IE for example, do you get the same error?

Because, this could be related to the issue that Selenium comes configured to work with Firefox version 3.6 (long distance from today's 7.0.1), so you could change that. Here is a guide that will help you change this.

One more thing, try adding in the setUp() function this line:

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

Hope this helps! Keep me posted.


I think this was caused by trying to run tests with a timeout which was too small. I increased the timeout and it was fine.

All browsers were ok except the one browser. The error reported is:

"Response from Selenium RC server for waitForPageToLoad(30000). Timed out after 30000ms"

I couldn't see the point in increasing the timeout period as it works for Selenium Server using the same browser version so it must be something to do with Sauce. In the end I did try increasing the time limit to 90seconds (90000) milliseconds which did the job. I have a theory that due to the extended test time when using Sauce that this must cause the script to timeout on this one browser. Anyway the solution is to increase the timeout as suggested by the error message.

I wrote about it here:

TestIgniter Blog Post

链接地址: http://www.djcxy.com/p/50750.html

上一篇: AngularJs结束

下一篇: 硒RC / PHPUnit测试总是超时?