co霸tjs的反应测试-没有找到可点击的元素的文本|CSS|XPath



我有一个项目与react和rest api(php+mysql)。我得让它通过codeception测试。该应用程序在无数的手动测试下正常工作,据我所知,co锥体测试也在工作,但它给出了以下错误:

Error: Clickable element "ADD" was not found by text|CSS|XPath
at new ElementNotFound (node_modules/codeceptjs/lib/helper/errors/ElementNotFound.js:14:11)
at assertElementExists (node_modules/codeceptjs/lib/helper/WebDriver.js:2835:11)
at WebDriver.click (node_modules/codeceptjs/lib/helper/WebDriver.js:917:7)
at processTicksAndRejections (internal/process/task_queues.js:97:5)I }) => {
I.amOnPage('/');
I.click('ADD');
I.seeElement('#product_form');
I.fillField('#sku', 'SKUTest000');
I.fillField('#name', 'NameTest000');
I.fillField('#price', '25');
I.waitForElement('#productType');
I.selectOption('#productType','DVD');
I.waitForElement('#size');
I.fillField('#size','200');
I.click('Save');

我的add元素是这样的:

<Link title="ADD" to="/add-product">ADD</Link>

有人可以帮助我,为什么这个错误出现,我怎么能解决它?提前感谢!

更新:我做了更多的测试,我注意到有时它会根据测试的时间返回更少/不同的错误。例如:

http://165.227.98.170/open?testName=ed
http://165.227.98.170/open?testName=ah
http://165.227.98.170/open?testName=bc

我的猜测是,这与react如何加载html元素和管理其他api调用有关。如何/我应该改变应用程序,以适应测试脚本?

似乎问题是我把整个主页的加载后,其余api调用意外。

最新更新