CodeCeption看不到字段,但浏览器确实(Chrome驱动程序)



i在Angular 5应用程序上进行了编码测试。使用HTML5漂亮的网址。
我正在测试2个步骤。

url: /register/ fields: first_name,email,password  
when success redirect to:  
url: /personal-details/ fields: date_of_birth 

第一步非常好。我测试了所有场景。当步骤一结束时,浏览器将以预期的html5重定向重定向到/personal-details/
问题在于,即使存在#date_of_birth也没有看到#Date_Of_Birth。
为了验证这一点,我在执行和运行控制台中pu

  document.getElementById('date_of_birth') 

发现了田地。它在页面上。

i虽然它与重定向有关,因此我添加了一个特殊的重定向以使第一个形式存在相同的问题,并且正常工作。

这是错误:

测试字段第二步

 Test  testsacceptanceFirstCest.php:testFieldsSecondStep
 Step  See element "#date_of_birth"
 Fail  Failed asserting that an array is not empty.

方案步骤:

什么可能出了问题?
谢谢

也许可以检查页面满载之前是否存在元素。
尝试使用Waitforelement而不是SeeElement

$I->waitForElement('#date_of_birth', 10);

我遇到了这篇文章,遇到了类似的问题。因为(我认为(没有正当理由我收到消息

'失败,断言数组不是空的。'

使用 $ i-> canSeeelement(( $ i-> canSeeelementIndom((。就我而言,我没有处理异步加载的元素,这些元素存在。

这就是我的代码的样子:

$I->canSeeElementInDOM('//*[@id="MyId"]//input[@name="myCheckbox"][not(@checked)]');

使用以下语法解决了问题:

$I->canSeeElementInDOM('//*[@id="MyId"]//input[@name="myCheckbox" and not(@checked)]');

希望这对某人也有帮助。

最新更新