Go down
Posts : 1
Join date : 2012-08-17

javascript variables not assigning correctly Empty javascript variables not assigning correctly

on Fri Aug 17, 2012 10:10 pm
I am trying to get the raw HTML of the page with this:


var info; $.get('webpage', function(data) { $('.response').html(data);info = data;}); alert(info);

In firefox running without selenium I get the pages raw html in a alert box. In selenium i use this:


((JavascriptExecutor)driver).executeScript("var info; $.get('webpage', function(data) { $('.response').html(data);info = data;}); alert(info);", "");

and info is undefined.

However this (alert inside function):


((JavascriptExecutor)driver).executeScript("var info; $.get('webpage', function(data) { $('.response').html(data);info = data; alert(info);});", "");

outputs the correct info. Is there any way to get the value of data from the function?
Back to top
Permissions in this forum:
You cannot reply to topics in this forum