Re: Execute console commands in Firefox using Selenium Webdriver

1,104 views
Skip to first unread message
Message has been deleted

skonthebass

unread,
Oct 11, 2013, 9:57:41 AM10/11/13
to seleniu...@googlegroups.com


On Friday, October 11, 2013 6:33:42 AM UTC-4, Essdee wrote:
Hi Guys,

I was trying to retrieve values automatically from the browser. I noticed I can get those values from the console by typing commands.

Could you please help and guide me to execute the commands in FF console (currently using Firebug) using Selenium webdriver.













My command is something like the below:
s.evarx

I want to execute the above command and retrieve that value using selenium. Is there a command that will help to achieve this?

Need your help guys...

Thanks in advance...
Essdee

David

unread,
Oct 14, 2013, 2:55:58 PM10/14/13
to seleniu...@googlegroups.com
You could do something like:

((JavascriptExecutor) driver).executeScript("return s.evarx;");

simply replace "return s.evarx;" with whatever javascript you execute in the Firebug console that you want to do with WebDriver. Most of the code you want can be executed this way, but not all.

Be sure to add a "return" keyword to the javascript code to execute if you are expecting to get the result/data. Otherwise, no need to if you are just executing code to do something.

An example that isn't helpful when executed via Selenium: "console.log('something to log');" unless you actually extract and deal with Firefox logs via Selenium, a separate topic.
Reply all
Reply to author
Forward
0 new messages