11

I am created test using this tutorial http://net.tutsplus.com/tutorials/php/how-to-use-selenium-2-with-phpunit/. And all work fine, but I can launch this test only on Firefox. I read a lot of articles about this in internet, but I don't find any solution. I have Windows XP, PHP 5.4.7, PHPUnit 3.7.13 by Sebastian Bergmann. Before running test I launched selenium-server-standalone-2.28.0.jar. There is my test

<?php
class Example extends PHPUnit_Extensions_Selenium2TestCase
{   protected function setUp()
    {   
    $this->setBrowser("firefox");
        $this->setBrowserUrl('http://test.com/');
    }

    public function testogin()
    {
        $this->url('http://test.com/');
        $this->timeouts()->implicitWait(10000);
        $username = $this->byId('user_login');
        $username->value('test.ru');
        $password = $this->byId('user_pass');
        $password->value('test');
        $this->byId('login_btn')->click();
    }
}
?>

Please, help me run this test on other browsers. If you need more information, ask me. Thanks

oleg_star
  • 246
  • 2
  • 11
  • For IE: See my answer in http://stackoverflow.com/questions/11982954/howto-start-internetexplorerdriver-in-phpunit-tests/15479565#15479565 – macio.Jun Mar 18 '13 at 14:50

2 Answers2

20

For Chrome:

  • Glance through the docs
  • Download the ChromeDrive
  • Start Selenium with extra argument: java -jar selenium-server-standalone-<version>.jar -Dwebdriver.chrome.driver=/path/to/chromedriver.exe
  • Now do $this->setBrowser('chrome'); in your setUp()-method

I have not tried the IE Driver yet, so I cannot do more for you then point to the docs.

Lastly, try and run your tests on all these browsers, you can give an array with all browsers: https://phpunit.de/manual/4.8/en/selenium.html Again, I haven't tried this one myself yet, so I cannot be more specific then those docs.

Hopefully I have given you enough pointers now... :)

Anyone
  • 2,814
  • 1
  • 22
  • 27
qrazi
  • 1,406
  • 1
  • 15
  • 18
  • 1
    New URL for Chrome driver download: https://sites.google.com/a/chromium.org/chromedriver/ – Pavel Nov 24 '14 at 22:37
6

For IE:

  • Download the InternetExplorerDriver
  • Start Selenium with extra argument:

    java -jar selenium-server-standalone-.jar -Dwebdriver.chrome.driver=/path/to/chromedriver.exe -Dwebdriver.ie.driver=/path/to/IEDriverServer.exe

  • Now do $this->setBrowser('iexplore'); in your setUp()-method

Roman
  • 128
  • 1
  • 6
TOS
  • 103
  • 1
  • 9