'QATester weird Error: clickable element "ADD" was not found by text|CSS|xpath

Sup Guys! I'm finishing an Assesment related to an PHP/MySql App; I have learning from scratch since I have never seen PHP before, and I have to admit that I would never have gotten this far if it hadn't been for your help. Now...the App runs smoothly and fullfill every functionalities, thing is when I try to run the QATest, everyone pass through, except one: Error: clickable element "ADD" was not found by text|CSS|xpath This error its driving me nuts, as ADD button runs ok on the remaining test. Here is my Index.php:

<?php include("db.php"); ?>


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>TEST ASSESMENT</title>
    <!--- Bootstrap CSS --->
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body>
    <div class="header"style="margin-top:50px;">  
    <form action="delete_product.php" method="post">      
        <div class="alignButton" style="display:flex; justify-content:space-between">
            <a style="margin-left:30px;text-decoration:none;color:black;font-size:30px;" href="index.php">Product List</a>
            <div class="alignButtons" style="display:flex; justify-content:flex-end">
                <button  style="margin-right:50px;" id="add" type="button" class="btn btn-primary" name="add" onclick="window.location.href='product_add.php'">ADD</button>    
                <button   style="margin-right:50px;" id="delete-product-btn" type="submit" name="mass_delete" class="btn btn-danger">MASS DELETE</button>   
            </div>
           
        </div>
        <hr/>
    </div>

    <div  class="py-5">
        <div class="container">
            <div class="row hidden-md-up">
             <!--Get all products from DB-->
            <?php
                $query = "SELECT * FROM products";
                $result_products = mysqli_query($conn, $query);
                while($row = mysqli_fetch_array($result_products)) { ?> 
                
                <!-- <?php 
                    if(isset($_SESSION['status'])){
                        echo "<h4>".$_SESSION['status']."</h4>";
                        unset($_SESSION['status']);
                    }
                ?>   -->
                <div class="col-sm-4">
                    <div class="card" style="margin:10px;padding:10px;width:250px;">
                        <input class="delete-checkbox" type="checkbox" name="check_list[]" value="<?php echo $row['id']; ?>">
                        
                        <label><?php echo $row['sku']; ?> : <?php echo $row['prod_type']; ?></label>
                        <h5><?php echo $row['name']; ?></h5>
                        <p>$<?php echo $row['price']; ?></p>
                        <!--Conditional rendering depending on product type-->
                        <?php if ($row['prod_type'] == 'DVD'): ?>
                        <p>Size: <?php echo $row['dvd']; ?>MB</p>

                        <?php elseif ($row['prod_type'] == 'BOOK'): ?>
                        <p>Weight: <?php echo $row['book']; ?> Kgs.</p>

                        <?php elseif ($row['prod_type'] == 'FUR'): ?>
                        <p> H:<?php echo $row['fur_h']; ?>x W:<?php echo $row['fur_h']; ?>x L:<?php echo $row['fur_l']; ?></p>  

                        <?php endif ?>

                    </div>
                </div>    
            <?php } ?>        
            </div>        
        </div>
    </div>
</form>
</div>

      
<!--- Bootstrap JS --->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
</body>
</html> 
    

And here is the QATester issue:

Check homepage basic requirements 951ms 

Error: Clickable element "ADD" was not found by text|CSS|XPath

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

The 11th following test passes ok. Even the button MASS DELETE on the same test.I have tried to Switch button order ( Mass Delete & Add), declare them with class/id; Rename button to add,Add,ADD; moved the button outside container div... can´t figure out what's the problem or what I have missing. I would really appreciate any help/clue/tip about it. Regards in Advance! Following test related to ADD button working



Solution 1:[1]

I had the same problem. Just put bigger margin between buttons :)

Solution 2:[2]

Answer: Just add the text ADD in the add button. it will pass. If you have multiple navigation for different page. type the exact 'ADD' text inside the button tag.

This is my navigation and it worked: it is in react, but similar with the html

 <header>
  <nav className="nav px-3 m-auto d-flex justify-content-between align-items-center border-bottom">
    <h3 className="nav-title">
      <Link to="/">Product {isProductListPage ? "List" : "Add"}</Link>
    </h3>
    <div className="nav-list d-flex align-items-center">
      <Link to="/add-product">
        <button className="nav-list-add btn me-3">
        ADD
        </button>
      </Link>
      <button id="delete-product-btn" onClick={handleDelete} className="btn btn-danger">MASS DELETE</button>
    </div>
  </nav>
</header>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Oskars Lejnieks
Solution 2