Inconsistent form and tab opening behavior (using 'SelectWindow')

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:

  1. 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.

  2. 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?

Thank you!

This sounds like a more tricky issue. Do you have a small test macro for us? Or maybe at least a screen video?

This means that you are using a wrong XPath locator. The RPA software does not find it, then tries another locator from the list, and this one works. If you use the “other” locator right away you can save time. This might also be the reason for the timeout issue you report in the other post!

Example XPath locator list as generated by Selenium IDE++ during recording:

image

I am happy to paste more of the code but unfortunately it is querrying/loading a search/form within a proprietary system which I cannot share on a public forum.

{
“Name”: “sub_batch affinityxxxxxx”,
“CreationDate”: “2021-10-15”,
“Commands”: [
{
“Command”: “store”,
“Target”: “fast”,
“Value”: “!REPLAYSPEED”,
“Description”: “”
},
{
“Command”: “selectWindow”,
“Target”: “tab=open”,
“Value”: “http://internaltools.xxxxxxxxxxxx”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “id=search-input”,
“Value”: “”,
“Targets”: [
“id=search-input”,
“xpath=//[@id="search-input"]",
“xpath=//input[@id=‘search-input’]”,
“xpath=//input”,
“css=#search-input”
],
“Description”: “”
},
{
“Command”: “type”,
“Target”: “id=search-input”,
“Value”: “${MyCsvArray[${f}][0]}”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “xpath=/html/body/div[4]/div[2]/div[2]/button/div”,
“Value”: “”,
“Targets”: [
“xpath=/html/body/div[4]/div[2]/div[2]/button/div”,
“xpath=//button/div”,
“css=body > div.main > div.head-bar > div.search-box > button > div”
],
“Description”: “”
},
{
“Command”: “click”,
“Target”: "xpath=//
[@id="search-url-result"]/div/ul/li/div/div/p”,
“Value”: “”,
“Targets”: [
“xpath=//[@id="search-url-result"]/div/ul/li/div/div/p",
“xpath=//p”,
“css=#search-url-result > div > ul > li > div.xxxxxx > div.xxxxxx > p”
],
“Description”: “”
},
{
“Command”: “click”,
“Target”: “id=labels-p”,
“Value”: “”,
“Targets”: [
“id=labels-p”,
"xpath=//
[@id="labels-p"]”,
“xpath=//p[@id=‘labels-p’]”,
“xpath=//li[2]/p”,
“css=#labels-p”
],
“Description”: “”
},
{
“Command”: “click”,
“Target”: “xpath=//[@id="opt-All Users"]/span",
“Value”: “”,
“Targets”: [
"xpath=//
[@id="opt-All Users"]/span”,
“xpath=//div[3]/div/ul/li[2]/span”,
“css=#opt-All Users > span”
],
“Description”: “”
},
{
“Command”: “click”,
“Target”: “id=user-group-p”,
“Value”: “”,
“Targets”: [
“id=user-group-p”,
“xpath=//[@id="user-group-p"]",
“xpath=//p[@id=‘user-group-p’]”,
“xpath=//li[3]/p”,
“css=#user-group-p”
],
“Description”: “”
},
{
“Command”: “click”,
“Target”: "xpath=//
[@id="opt-Affinity Groups"]/span”,
“Value”: “”,
“Targets”: [
“xpath=//[@id="opt-Affinity Groups"]/span",
“xpath=//div[2]/div/ul/li[3]/span”,
“css=#opt-Affinity Groups > span”
],
“Description”: “”
},
{
“Command”: “click”,
“Target”: “id=group-value-p”,
“Value”: “”,
“Targets”: [
“id=group-value-p”,
"xpath=//
[@id="group-value-p"]”,
“xpath=//p[@id=‘group-value-p’]”,
“xpath=//li[4]/p”,
“css=#group-value-p”
],
“Description”: “”
},
{
“Command”: “click”,
“Target”: “xpath=//[@id="opt-Health & Fitness"]/span",
“Value”: “”,
“Targets”: [
"xpath=//
[@id="opt-Health & Fitness"]/span”,
“xpath=//div[2]/div/ul/li[6]/span”,
“css=#opt-Health & Fitness > span”
],
“Description”: “”
},
{
“Command”: “click”,
“Target”: “id=source-p”,
“Value”: “”,
“Targets”: [
“id=source-p”,
“xpath=//[@id="source-p"]",
“xpath=//p[@id=‘source-p’]”,
“xpath=//li[7]/p”,
“css=#source-p”
],
“Description”: “”
},
{
“Command”: “click”,
“Target”: “id=opt-b_m_activation”,
“Value”: “”,
“Targets”: [
“id=opt-b_m_activation”,
"xpath=//
[@id="opt-b_m_activation"]”,
“xpath=//li[@id=‘opt-b_m_activation’]”,
“xpath=//li[7]/div[3]/div/ul/li[6]”,
“css=#opt-b_m_activation”
],
“Description”: “”
},
{
“Command”: “click”,
“Target”: “id=author-p”,
“Value”: “”,
“Targets”: [
“id=author-p”,
“xpath=//[@id="author-p"]",
“xpath=//p[@id=‘author-p’]”,
“xpath=//li[10]/p”,
“css=#author-p”
],
“Description”: “”
},
{
“Command”: “click”,
“Target”: “id=opt-thomas”,
“Value”: “”,
“Targets”: [
“id=opt-thomas”,
"xpath=//
[@id="opt-xxxxx"]”,
“xpath=//li[@id=‘opt-xxxxxx’]”,
“xpath=//li[10]/div[2]/div/ul/li[8]”,
“css=#opt-thomas”
],
“Description”: “”
},
{
“Command”: “click”,
“Target”: “id=option-customheader”,
“Value”: “”,
“Targets”: [
“id=option-customheader”,
“xpath=//[@id="option-customheader"]",
“xpath=//li[@id=‘option-customheader’]”,
“xpath=//div[3]/ul/li[12]”,
“css=#option-customheader”
],
“Description”: “”
},
{
“Command”: “click”,
“Target”: “id=custom_header”,
“Value”: “”,
“Targets”: [
“id=custom_header”,
"xpath=//
[@id="custom_header"]”,
“xpath=//input[@id=‘custom_header’]”,
“xpath=//li[12]/input”,
“css=#custom_header”
],
“Description”: “”
},
{
“Command”: “type”,
“Target”: “id=custom_header”,
“Value”: “xxxxxxxx”,
“Targets”: [
“id=custom_header”,
“xpath=//*[@id="custom_header"]”,
“xpath=//input[@id=‘custom_header’]”,
“xpath=//li[12]/input”,
“css=#custom_header”
],
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return Number (${f}) + 1;”,
“Value”: “f”,
“Description”: “”
}
]
}

Right but most of the time this locator works!

Also, can I really use the very simple locator it suggests - just xpath=//p ? Seems very generic!

Can you post a screencast of the macro running?

You mean like the code executing in the UI.Vision window? Or the macro running in the proprietary backend?

Giving this a bumpity bump bump bump