codeceptjs react测试 - 文本| css | xpath找不到点击元素

发布于 2025-01-22 13:36:00 字数 1281 浏览 3 评论 0原文

我有一个由React和Rest API(php+MySQL)制成的项目。我必须通过CodeCeptJS测试进行。该应用程序正在适当地使用无数的手动测试,据我所知,CodeCeptJS测试正在工作。同样,但是它给出了以下错误:

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');

我的添加元素看起来像这样:

<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

我的猜测是与html元素中的反应负载和管理剩下的API调用有关。在应用程序中如何/应该如何更改测试脚本?

I have a project made with react and rest api(php+mysql).I have to put it through a codeceptjs test.The app is working properly with countless of manual testing, and as far as I can see, the codeceptjs test is working too, but it gives the following error:

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');

My add element looks like this:

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

Can someone please help me out why is this error appearing and how can I solve it? Thanks in advance!

Update:
I did a couple more tests, and I noticed that sometimes it gives back less/different errors depending on the test's time. For example:

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

My guess is that is has to do with how react loads in the html elements and manages the rest api calls. How/what should I change in the app to accomodate the test script?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

停顿的约定 2025-01-29 13:36:00

似乎问题是我偶然地将整个主页的负载放在整个主页上。

Seems like the problem was I put the whole home page's load after the rest api call by accident.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文