selenium网络驱动程序-在Chrome和IE中启动phpunit-selenium2测试



我是使用本教程创建测试的http://net.tutsplus.com/tutorials/php/how-to-use-selenium-2-with-phpunit/.一切都很好,但我只能在Firefox上启动这个测试。我在网上读了很多关于这方面的文章,但我没有找到任何解决方案。我有Sebastian Bergmann的Windows XP,PHP 5.4.7,PHPUnit 3.7.13。在运行测试之前,我启动了硒服务器-标准-2.28.0.jar。这是我的测试

<?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();
    }
}
?>

请帮助我在其他浏览器上运行此测试。如果您需要更多信息,请询问我。谢谢

对于Chrome:

  • 浏览文档
  • 下载ChromeDrive
  • 使用额外的参数启动Selenium:java -jar selenium-server-standalone-<version>.jar -Dwebdriver.chrome.driver=/path/to/chromedriver.exe
  • 现在在setUp()-方法中执行$this->setBrowser('chrome');

我还没有尝试IE驱动程序,所以我不能为你做更多的事情,然后指向文档。

最后,尝试在所有这些浏览器上运行测试,您可以为所有浏览器提供一个数组:https://phpunit.de/manual/4.8/en/selenium.html同样,我自己还没有尝试过这个,所以我不能比那些医生更具体。

希望我现在已经给了你足够的建议…:)

对于IE:

  • 下载InternetExplorer驱动程序
  • 用额外的参数启动Selenium:

    java-jar硒服务器单机版--.jar-Dwebdriver.chrome.driver=/path/to/chromedriver.exe-Dwebdriver.ie.driver=/path/to/IEDriverServer.exe

  • 现在执行$this->setBrowser('explore');在您的setUp()-方法中

最新更新