I have a looping subroutine that inserts a value from a CSV file to a search bar, then clicks on the first search result and fills in a pop-up form, and I am having an issue where the routine is pausing/waiting for no apparent reason.
The issue occurs between the second and third steps below:
Essentially, the routine hits inserts the value to the search bar (step 1 above), clicks the search button search (step 2)… and then waits 10 seconds before executing step 3, even though the element (the search result) appears almost immediately.
After the delay it selects the search result, then moves through the rest of the routine at normal speed with no delays.
During the delay a numbered countdown ‘waiting’ badge is displayed on the UI.Vision button and the macro status bar displays “waiting 5 secs” (then 4,3,2, etc). No error or warning appears in the log coinciding with the delay.
This routine needs to run like 60-100 times per execution of the parent macro, so this really slows things down, like adding an extra 10 minutes(!) per 60 runs.
Is there a way to force it to execute as soon as the element appears, rather than invoking this apparently pre-set delay?
Remembering now that I tried this earlier and it does kind of work, but not perfectly. And I just tested your suggestion now to confirm.
If the system is working perfectly, this works, but if the system is running slowly, or one particular query causes a delay - basically if the system is slow to return search results - it causes a problem, since it forces the sub to continue before the element is present.
So maybe a better/more specific question to ask is: is there a way to have it click/execute as soon as the element is present, rather than after a static delay value?
UI Vision and similar tools like Selenium IDE wait for the element to be loaded before moving to the next step (" implicit waiting"). This should be exactly what you need. But what can happen is that the element that you need might be seen already, but other parts of the DOM of the page are not complete, and therefore the element is not found (yet).
You can avoid this by replacing the CLICK command with the visualXClick | image command. Then UI Vision completely ignores what goes on inside the web page, and looks at the page just like a human does.
Believe it or not I actually first wrote the code with Xclick at that location, and used it that way for a month or so (1000+ runs).
However, Since that was my only ‘X’ command, I recently switched it recently to enable running >25 repetitions. But - I swear - the original version (using Xclick) consistently encountered the same delay.