Getting UnexpectedJavascriptExecutionException: while using getEval

158 views
Skip to first unread message

Rohit

unread,
Dec 24, 2009, 5:10:11 PM12/24/09
to webdriver
I am getting UnexpectedJavascriptExecutionException when trying to use
getEval method while using WebDriverBackedSelenium. it works fine if i
use only selenium.

It also works fine if i use runScript() instead of getEval() method.

here is the code sample

WebDriver driver = new InternetExplorerDriver();

String baseUrl = "http://www.google.com";

final Selenium selenium = new WebDriverBackedSelenium(driver,
baseUrl);

selenium.open("");
selenium.getEval("window.document.getElementsByName('q')[0].tagType");


Stack Trace
--------------------
Exception in thread "main" I03:32:37:420 .\IEThread.cpp(655)
-2147352567 [Exception occurred.]: Exception message was: Expected
')': (function() { return function(){return eval
('window.document.getElementsByName('q')[0].tagType');};})();
org.openqa.selenium.ie.UnexpectedJavascriptExecutionException: Cannot
execute script
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1',
java.version: '1.6.0_14'
Driver info: driver.version: ie
at org.openqa.selenium.ie.ErrorHandler.verifyErrorCode
(ErrorHandler.java:68)
at org.openqa.selenium.ie.InternetExplorerDriver.executeScript
(InternetExplorerDriver.java:163)
at
org.openqa.selenium.internal.seleniumemulation.GetEval.handleSeleneseCommand
(GetEval.java:56)
at
org.openqa.selenium.internal.seleniumemulation.GetEval.handleSeleneseCommand
(GetEval.java:25)
at
org.openqa.selenium.internal.seleniumemulation.SeleneseCommand.apply
(SeleneseCommand.java:30)
at org.openqa.selenium.WebDriverCommandProcessor.execute
(WebDriverCommandProcessor.java:270)
at org.openqa.selenium.WebDriverCommandProcessor.getString
(WebDriverCommandProcessor.java:241)
at com.thoughtworks.selenium.DefaultSelenium.getEval
(DefaultSelenium.java:461)


Can somebody help me solve this issue

cheers,
Rohit

Steve CCRP

unread,
Dec 24, 2009, 6:22:52 PM12/24/09
to webdriver
Here's a guess. Looking at the stack trace, I think you should try
using double quotes:

selenium.getEval("window.document.getElementsByName(\"q\")
[0].tagType");

Tell us how it goes.

-Steve

Rohit Maurya

unread,
Dec 25, 2009, 11:20:16 AM12/25/09
to webd...@googlegroups.com
Hi,

Thanks for the suggestion it is working fine after adding the double quotes.

Cheers

Rohit

--

You received this message because you are subscribed to the Google Groups "webdriver" group.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.



Rohit Maurya

unread,
Dec 25, 2009, 11:23:21 AM12/25/09
to webd...@googlegroups.com
Hi,

is there any specific reason why we need to add the double quotes. can you please elaborate on the reason of why it was failing. as the same thing works if i do  selenium.runScript() or using JavascriptExecutor without using double quotes.

-Rohit

Daniel Wagner-Hall

unread,
Dec 25, 2009, 11:30:04 AM12/25/09
to webd...@googlegroups.com
You shouldn't have to use double quotes, it's a bug in WebDriver.
I've just filed it as a bug so that we remember to fix it:
http://code.google.com/p/selenium/issues/detail?id=292
Reply all
Reply to author
Forward
0 new messages