Possible typecasting problem and anyone use Selenium/WebDriver with Beanshell?
David Luu <[email protected]> Thu, 16 Aug 2012 11:13:31 -0700
| Newsgroups | gmane.comp.java.beanshell.user |
|---|---|
| Message-ID | <CA+V6+ZA1nzr8wyy1xocS4ik+QiASCMe5vFb80q1B-1uLb_xA3g@mail.gmail.com> |
Hello,
I don't know the internals of Beanshell nor WebDriver to be able to
determine the source problem, but hopefully others can help me shed some
light on this. I also know Beanshell is no longer being developed but any
help appreciated. I'll also gonna try with the new Beanshell2 fork and see
what I can get off there.
Using standard boilerplate example Java code to execute javascript with
WebDriver (FF or IE driver, doesnt' matter), using the example online, e.g.
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.*;
WebDriver driver = new FirefoxDriver();
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("some js here");
this runs fine under Java. Now try same code snippet under Beanshell. Get
such an exception (exact message varies by actual browser driver used):
EvalError: Error in method invocation: Method executeScript(
java.lang.String ) not found in
class'org.openqa.selenium.firefox.FirefoxDriver'.
Since code works in Java, this must be a Beanshell specific issue. But the
error message is rather vague. And since I'm not a Selenium dev nor do I
work closely with the core Java class bindings, I have no idea what the
error may be about.
My best guess is that it can't find the proper class reference to
executeScript method. Somehow referencing needs to work differently in
Beanshell? Or typecasting doesn't work? According to the docs,
JavascriptExecutor is an interface that is implemented in the different
browser WebDrivers.
FYI, I start up Beanshell with reference to Selenium JAR already as follows:
java -cp selenium-server-standalone-2.24.1.jar;bsh-2.0b4.jar bsh.Interpreter
Standard WebDriver and WebElement commands work fine like get(),
findElement(), click(). I just can't execute javascript.
Regards,
David
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/