Hi there!
I´m quite new to Selenium in general and I have a general and a more detailed question which I could not solve with google or stackoverflow etc.
I hope you can help me.
I´m using Selenium WebDriver with Java.
I have an automated test written in Java which is working. Fine so far.
One of the html pages has a script on its page hardcoded. This script has some variables and objects.
My aim: I´d like to access all the variables and values of that particular page and get them into a separate file later.
My question: is that even possible with Selenium to get those values? And if yes, then how do I get them?
For example:
I wanted to start small and to access "name3" and its values.
<html>
...
<script id="id_name" type="application/json">{"name" : "value",
"name2" : { "name3" : "value3"},...
</script>
What I did until now:
JavascriptExecutor js = (JavascriptExecutor) driver;
Object value = js.executeScript("return document.name3;");
System.out.println("name3:" + value);
value is null in this case. This is false, it should be a string.
What am I missing?
Thanks for any advice.