我使用本教程http://net.tutsplus.com/tutorials/php/how-to-use-selenium-2-with-phpunit/創建測試。所有工作都很好,但我只能在Firefox上啓動此測試。我在網上閱讀了很多關於這方面的文章,但我沒有找到任何解決方案。我有Windows XP,PHP 5.4.7,Sebastian Bergmann的PHPUnit 3.7.13。在運行測試之前,我啓動了selenium-server-standalone-2.28.0.jar。還有就是我的測試在Chrome和IE中啓動phpunit-selenium2測試
<?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();
}
}
?>
請幫我跑在其他瀏覽器測試。如果您需要更多信息,請問我。由於
發佈錯誤日誌。 – Manigandan
對於IE: 請參閱我的答案http://stackoverflow.com/questions/11982954/howto-start-internetexplorerdriver-in-phpunit-tests/15479565#15479565 –