AutoQA 测试在清晰可见且不与任何其他元素发生冲突时找不到我的按钮

AutoQA test not finding my button when it's clearly visible & not clashing any other element

我在 QA 测试中遇到了问题,它抛出了这个错误:


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('MASS DELETE');
        I.click('ADD');

虽然此测试通过:

I }) => {
        I.amOnPage('/');
        I.click('ADD');
        I.seeElement('#product_form');
        I.seeElement('#sku');
        I.seeElement('#name');
        I.seeElement('#price');
        I.seeElement('#productType');

注意我正在使用 React & 按钮是来自 React Router 的标签;我也试过将其切换为常规 标记、四处移动、更改名称,但似乎没有任何效果。

P.S这是一个自动化测试,我对它的控制为0,无法更改测试参数,只能更改我的代码,如下所示:

   <Link className="button button--primary space ADD" to="/add-product"         
      ADD
   </Link>

作为替代方案,您可以使用以下任一方法 :

  • cssSelector:

    I.click('Link.button.button--primary.space.ADD');
    
  • xpath:

    I.click('//Link[@className="button button--primary space ADD"]');
    

问题是它先按了 MASS DELETE 并且当没有选中复选框时我没有阻止默认行为,并且我在后端而不是前端处理错误。