zer*_*kms 7 php testing selenium phpunit selenium-webdriver
对于C#,有一种方法可以编写一个语句来等待页面上的元素出现:
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
IWebElement myDynamicElement = wait.Until<IWebElement>((d) =>
{
return d.FindElement(By.Id("someDynamicElement"));
});
Run Code Online (Sandbox Code Playgroud)
但有没有办法在phpunit的selenium扩展中做同样的事情?
我发现的唯一的事情是$this->timeouts()->implicitWait(),但显然它不是我想要的.
这个问题是关于Selenium2和PHPUnit_Selenium2相应的扩展.
将implicitWait你发现的是,您可以改用waitForCondition什么.正如WebDriver API的规范(您也发现;))指出:
隐式 - 设置驱动程序在搜索元素时应等待的时间.搜索单个元素时,驱动程序应轮询页面,直到找到元素或超时到期,以先发生者为准.
例如,在单击它之前,此代码将等待最多30秒才能显示元素:
public function testClick()
{
$this->timeouts()->implicitWait(30000);
$this->url('http://test/test.html');
$elm = $this->clickOnElement('test');
}
Run Code Online (Sandbox Code Playgroud)
缺点是它设置了会话的生命周期,并可能减慢其他测试,除非它被设置回0.
| 归档时间: |
|
| 查看次数: |
3637 次 |
| 最近记录: |