Reputation: 181
I want to use WebDriver to execute some javascripts on the application i am testing. Im using the following code:
JavascriptExecutor js = (JavascriptExecutor) driver;
String label = (String)js.executeScript("return document.g.nodes[1].label", null);
g global javascript object in the page. if i inspect it from the console using inspect elements i see that everything is there... though when i execute this script im thrown an exception stating "Cannot create node property from undefined".
Witch g is for some reason undefined in the page.
anyone have any ideas?
its not a problem with timing since im working in debug and manually wating for page to load completly.
thanks
Upvotes: 0
Views: 4130
Reputation: 11391
Aren't javascript objects attached to window rather than document?
At least I have always used window.whatever from webdriver and it works nicely.
Upvotes: 1