- whitefoxsniper
- Posts : 1
Join date : 2012-08-17
javascript variables not assigning correctly
Fri Aug 17, 2012 10:10 pm
I am trying to get the raw HTML of the page with this:
In firefox running without selenium I get the pages raw html in a alert box. In selenium i use this:
and info is undefined.
However this (alert inside function):
outputs the correct info. Is there any way to get the value of data from the function?
- Code:
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:
- Code:
((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):
- Code:
((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?
Permissions in this forum:
You cannot reply to topics in this forum