I am working with a page source that runs Javascript to print text on the page. Here is a snippet of the source I'm speaking of:
var display_session = get_cookie("LastMRH_Session");
if(null != display_session) {
document.getElementById("sessionDIV").innerHTML = '<BR>The session reference number: ' + display_session + '<BR><BR>';
document.getElementById("sessionDIV").style.visibility = "visible";
}
The page is displaying the value of the display session
variable when it's not null but I want to know if there is a way I can utilize this variable in my Selenium WebDriver code. The function that uses this code in the Javascript does not return the display_session
variable and I cannot alter the page source. I tried this based on the post here but it throws an exception.
JavascriptExecutor js = (JavascriptExecutor) driverRp;
Object result = js.executeScript("return display_session");
System.out.println("sessionId = "+result);
Any suggestions?