Selenium sending commands into Chromes Console

3,679 views
Skip to first unread message

Joe Early

unread,
Aug 15, 2013, 12:02:46 PM8/15/13
to seleniu...@googlegroups.com
Hi all 

we are testing a anaimtion that works on event IDs. These come from a server but we also use the chrome console to send them locally for playback of certain events. 

How can I use selenium web driver to send a command such as "t.se(1024)" to the console and hit enter. 

I will then be testing what appears on the animation 

Any pointer links would be great

Thanks
j

David

unread,
Aug 18, 2013, 2:39:59 PM8/18/13
to seleniu...@googlegroups.com
Executing commands in the Chrome console for the most part is simply executing javascript code. So if my assumption that "t.se(1024)" is actually a call to a (special?) javascript object t with method se, then you could just execute like follows in Selenium Java:

((JavascriptExecutor) driver).executeScript("t.se(1024);");

if you needed to get back the return value of a command then it could be something like:

String value = (String) ((JavascriptExecutor) driver).executeScript("return t.se(1024);"); //assuming it does return string, otherwise typecast as needed
Reply all
Reply to author
Forward
0 new messages