I have a scenario where I need to enter values in different cells of a row.
I am able to click the ‘Add row’ button but when I try to enter the value to the first cell, the object is not located correctly. I have tried using just the text or position as a locator but it did not work.
Adding screenshots for reference -
To really assist you, we will likely have to review the HTML to see the why of your concern. However, I have read another question on this forum about a similar issue. In that question, when the “Add row” button was checked, it added another row onto a table that had rows already. So, the “new” row was not the assumed first, but really the last, even though it was at the beginning of the table.
Can you right click on the cell you have highlighted, and select “Inspect” from the pop-up? Do this a second time. A HTML window will display showing the tag and attributes for your cell. Review the HTML and see if it has a better pathway than what you have given or show us so that we can assist.
I also remembered that the “new” row was not “available” by HTML right away. There was a fair bit of lag time–so you should perhaps add various waitFor statements, along with verifyElement statements before trying to add text to the cell.
Edit: we’re talking the speed that your script can run, not the speed you can do things manually.
Thanks for the response, I observed that the ‘delay’ works good when I run the script independently but when I call this particular case within another case, it still fails saying ‘Object is not interactable’.
Is there any specific reason that would be causing this.
Generally, when I get this concern, I put various tests above the statement to confirm the element is ready, such as
WebUI.verifyElementVisible(). In this case, I might even put in a temporary delay statement to see if the element is just not ready, like
WebUI.delay(5). (Might even go 10.) It is only temporary to see if timing is our issue. If the concern goes away after the delay, then you know you have to insert
WebUI.waitForElementClickable() to do a better delay system.
If the concern is still present after the temporary delay, then we need to verify the element you have via pathway is the actual one you want.
Another issue could be that something is overlaying your element, but that should be stated in the “error message”, like “Object is not interactable. Another object, button, would receive the click”.
Edit: I started thinking about “overlaying your element” and think you should make sure the element is in the “viewport” as well. If the entire page is in the viewport, then okay, however if you have to move down the page, then perhaps
WebUI.scrollToElement(..., 10) that is about 4 to 5 cm (2 inches) above the element you want to interact with.
Edit2: I am assuming you have the statement,
WebUI.maximizeWindow(), at or near the top of your script.