So there are several posts on how to query the dom to find an element by xpath. I found a post, Is there a way to get element by XPath using JavaScript in Selenium WebDriver?, that mostly meets my needs. My problem is stemming from the fact that the element I am trying to locate is a script, and that script needs to be loaded asynchronously. That seems to break finding its path using
var path = "//script[contains (@src, 'locationOfScript')]";
I think the root cause may be Chrome delaying the async script load until after the page is complete: Chrome delays load of script with async attribute.
I'm developing a userscript in Chrome, and must leave the script as async, otherwise I'd just drop the async attribute.
Any way to query the document for a script that won't load until after everything else?
Thanks!