0

I've created a test case by extending \PHPUnit_Extensions_Selenium2TestCase and specifiying the browsers using $browsers, in phpunit 3.7.21:

class SeleniumTest extends \PHPUnit_Extensions_Selenium2TestCase
{
    public static $browsers = array(
        array(
            'name' => 'Explorer on Windows',
            'browserName' => 'explorer',
            'host' => 'localhost',
        )
    );
}

But if I remove $browsers and try to configure the browsers in phpunit.xml by putting the following in the tags, as per the docs, the settings do not get read:

<phpunit
    bootstrap="../../TestModule/test/ModuleBootstrap.php"
    backupGlobals="false">
    <testsuites>
        <testsuite name="manager">
            <directory>./Test</directory>
        </testsuite>
    </testsuites>
    <selenium>
        <browser name="Firefox on Windows"
           browser="firefox"
           host="localhost"/>
        <browser name="Explorer on Windows"
           browser="explorer"
           host="localhost"/>
    </selenium>
</phpunit>

I've tried changing browser="explorer" to browserName="explorer" but in either case the settings are not getting picked up.

I believe it is not a connection issue as PHPUnit does not try to run the test for each browser. Is this feature supported in PHPunit / Selenium2?

3
  • Could you past the whole phpunit.xml? Commented Jul 1, 2013 at 20:20
  • Sure thing, I've added it to the original post. Commented Jul 2, 2013 at 11:10
  • The example in the docs extend PHPUnit_Extensions_SeleniumTestCase rather than PHPUnit_Extensions_Selenium2TestCase, so I am wondering if this is the reason. Commented Jul 2, 2013 at 11:17

1 Answer 1

3

The phpunit.xml solution only works for Selenium RC (and it's stated explicitly in the documentation).

For phpunit selenium 2 you have to follow your original idea with a static property.

Sign up to request clarification or add additional context in comments.

4 Comments

Ah ok, thanks for clarifying - I'm finding the Selenium naming conventions slightly confusing! In that case I'll settle for adding a constant for the selenium server address in phpunit.xml.
Well, it's not overly explicit, it says The <selenium> element and its <browser> children can be used to configure a list of Selenium RC servers. and that's it...could be more clear, maybe ...can only be used to configure...
Link to that quote: phpunit.de/manual/3.7/en/…
Also note that Phing does not support the <selenium> tag. May or may not apply to your situation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.