Locating a Web Element that disappears after Inspect
Two methods for inspecting disappearing dynamic elements
A repost of my daughter’s article, I added a few notes.
Dynamic elements are generated on the fly on a web page. This means they often do not exist in the static page source. This is a challenge for web test automation.
The only practical way (I am aware of) is to get it by Inspecting the dynamic element directly.
Zhimin’s notes: Hand crafting automated test scripts is the best way and only way I witnessed in successful test automation (for over 17 years). While many agree that Record/Playback is bad, some might fear hand-crafting. If doing properly, handcrafting is easy and fun, my daughter started hand-crafting raw Selenium test scripts since the age of 12, you (or your child) can do that too. Check out my Selenium Training Workbook.
However, some web elements disappear after you select the ‘Inspect’ menu item (via right-click), as their focus has been lost or the element has disappeared. Below is an example.