Hello all, and thanks in advance for your time.
I’m a low-intermediate user having some issues with tab opening behavior, and also with form value insertion. Both errors appear to be associated with an xpath locator warning, but I can’t figure out what I should do to resolve.
For context, the big picture is I am using a pair of macros/scripts - one as a parent/master, one as a subroutine. The master calls/loads into memory a CSV containing a list of links, then loops the subroutine. The subroutine opens a web page in a new tab (using ‘selectWindow’|tab=open), inserts the Nth link into a search bar on the site and clicks ‘search’, then selects the first search result. This opens a form, which the subroutine fills in according to static values (using ‘click’ to open dropdown menus and select values).
The two issues I am having are:
Inconsistent tab opening. Sometimes the subroutine will run as intended, opening one new tab for each new CSV line. 20 lines = 20 tabs. BUT other times, seemingly at random (maybe 1 in 5 times or 1/10), it will open 2-3+ blank tabs in between - so it still opens all 20 tabs, but each with 2-3 blank tabs in between - so like 60-80 tabs total.
Inconsistent form value insertion: So along with inserting the value from the CSV, the looping subroutine fills in a bunch of dropdown fields on the same form using ‘click’ + an xpath locator (EX. 'click|xpath=//[@id=“opt-All Users”]/span*). And most of the times this works perfectly - BUT sometimes it will randomly skip the first field. All the rest get filled in correctly.
When I check the execution log, what I find is that on the runs where one error or the other occurs, there is a warning generated:
" * [warning]Line 6 (Sub: sub_batch affinity push): Element found with secondary locator “xpath=//p”. To use it by default, update the target field to use it as primary locator."
This warning appears to occur at the same step each time: In each case, the subroutine will correctly open a new tab, insert the CSV value to the search bar, and search.
On successful runs, it clicks the first search result and proceeds to fill out the form.
On unsuccessful runs, the warning is generated when it attempts to click the result, causing one of two outcomes:
In one outcome case, the search result appears but is never successfully clicked, and something happens where the warning is repeated in the log several times in a row. The popup form never opens, and the sub eventually restarts on the next CSV value. This is outcome is associated with #1 above, where multiple blank tabs are opened.
In the second outcome case, the search result appears and the warning appears, but the search result is successfully clicked, the popup form appears, and the sub runs trough it successfully except for skipping the very first field in the form (see #2 above).
What is especially to me about this is that the problem is so variable. How can the xpath locator work fine 9/10 times, but fail the tenth?
How can I resolve this?