Locating Elements: testcase proceeding too fast - Web Performance
Menu

Locating Elements: testcase proceeding too fast

Try our free SeleniumIDE replacement

When a testcase proceeds faster than the application, it can have a seemingly impossible combination of symptoms, such as:

If you have the first three symptoms above, but not the last (i.e. the locator always fails), then it is possible that the target element is in an IFrame.

In the above case, every indication shows that the element is there, but the locator failed. How is that possible?

The cause becomes clear if you understand this important point: when a locator fails, there is a time delay before the HTML is captured and another before the screenshot is captured. These delays are not intentional – rather a limitation imposed by the APIs used to integrate with the browser. It is possible that the element may not have existed when the locator executed, but did exist when the page source and screenshot were captured. The time delay is typically very short (to a human) but plenty of time for the page’s DOM to change significantly.

Before attempting a solution, you should first verify this is really the cause. The easiest way is to add a significant amount of think time (several seconds?) just before the step with the failing locator. If this eliminates the problem (or measurably reduces it), then you can proceed to the fix.

How to fix?

The solution is stop the testcase from proceeding until the required condition is satisfied (e.g. the element exists).

Copyright © 2024 Web Performance, Inc.

A Durham web design company

×

(1) 919-845-7601 9AM-5PM EST

Just complete this form and we will get back to you as soon as possible with a quote. Please note: Technical support questions should be posted to our online support system.

About You
How Many Concurrent Users