我读过一些文章,他们说implicitWait()在全球范围内工作。但我不知道该把它放在哪里。
这是我的代码:
public function setUp(){
$this->setHost('10.10.60.95');
$this->setPort(4444);
$this->setBrowser('firefox');
$this->setBrowserUrl('http://www.ABC.com');
$this->prepareSession();
}
public function testTitle()
{
$this->url('http://www.ABC.com/');
$this->assertEquals('ABC', $this->title());
}我应该在哪里添加implicitWait()?setUp函数还是testTitle函数?
$this->超时值()->implicitWait(10000);
谢谢!
答案:
正如@Arran所说,实际上,在大多数情况下,我应该将这段代码放在setUp()函数中,因为它是全局工作的。
public function setUp(){
$this->setHost('10.10.60.95');
$this->setPort(4444);
$this->setBrowser('firefox');
$this->setBrowserUrl('http://www.ABC.com');
$this->prepareSession();
$this->timeouts()->implicitWait(10000);
}如果要为测试函数设置特殊的超时,可以在其中添加此代码。
public function testTitle()
{
$this->url('http://www.ABC.com/');
$this->timeouts()->implicitWait(5000);
$this->assertEquals('ABC', $this->title());
}发布于 2014-01-03 08:37:45
我想你有两个选择--你可以试试。虽然不是百分之百肯定他们,你可以尝试一下。请根据您的需要更换它们。
1.
// wait for at most 10 seconds until the URL is 'http://example.com/account'.
// check again 500ms after the previous attempt.
$driver->wait(10, 500)->until(function ($driver) {
return $driver->getCurrentURL() === 'http://example.com/account';
})
2.
$this->_session->timeouts()->implicit_wait(10000); // 1 sec = 1000https://stackoverflow.com/questions/20899404
复制相似问题