phpunit硒的使用 [英] phpunit selenium usage
问题描述
我的问题是关于phpunit + Selenium的使用.
该联合的标准用法是
My question is about phpunit+selenium usage.
The standard usage of this union is
class BlaBlaTest extends PHPUnit_Extensions_SeleniumTestCase
{... }
OR
class BlaBlaTest extends PHPUnit_Extensions_Selenium2TestCase
{...}
第一个(PHPUnit_Extensions_SeleniumTestCase
)使用起来不太方便
(例如,没有$this->elements('xpath')
之类的东西).
Second(PHPUnit_Extensions_Selenium2TestCase
)也具有有限的功能
(例如,没有waitForPageToLoad()
或clickAndWait()
这样的功能,
使用$this->timeouts()->implicitWait(10000)
之类的东西对我来说就像
完全废话.
The first one (PHPUnit_Extensions_SeleniumTestCase
) is not very convinient to use
(e.g. there is no such thing as $this->elements('xpath')
).
Second(PHPUnit_Extensions_Selenium2TestCase
) also has limited functionality
(e.g. there is no such functions as waitForPageToLoad()
or clickAndWait()
,
and using something like $this->timeouts()->implicitWait(10000)
looks for me like
complete nonsense).
是否可以使用功能
PHPUnit_Extensions_SeleniumTestCase + PHPUnit_Extensions_Selenium2TestCase
在一堂课上? 也许smb知道phpunit + Selenium的好选择吗?
in one test class? Maybe smb knows good alternatives to phpunit+selenium?
推荐答案
以丹为灵感
/**
* @param string $id - DOM id
* @param int $wait - maximum (in seconds)
* @retrn element|false - false on time-out
*/
protected function waitForId($id, $wait=30) {
for ($i=0; $i <= $wait; $i++) {
try{
$x = $this->byId($id);
return $x;
}
catch (Exception $e) {
sleep(1);
}
}
return false;
}
这篇关于phpunit硒的使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!