I need to invoke Selenium from Client Side, so I’m trying to run Selenium from a Java Applet in a static HTML page.
I’m using firefox 3.6.12 in SUSE Linux environment.
The HTML page looks like this
<HTML>
<HEAD>
</HEAD>
<BODY>
<APPLET ALIGN="CENTER" CODE="SeleniumTest.class" WIDTH="800"
HEIGHT="500" archive="/home/******/Selenium/selenium-2.20.0/selenium-
server-standalone-2.20.0.jar,/home/******/Selenium/selenium-2.20.0/
selenium-java-2.20.0.jar,/home/*******/Selenium/selenium-2.20.0/
selenium-firefox-driver-2.0a5.jar" ></APPLET>
</BODY>
</HTML>
The Applet was loaded and info statements were printed. But, during
the creation of webdriver, I’m getting the below exception in Java
Console and it stops there.
Exception in thread "AWT-EventQueue-8" java.lang.NoClassDefFoundError:
Could not initialize class
org.openqa.selenium.firefox.internal.Executable
at
org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:
56)
at
org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:
52)
at
org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:
84)
at SeleniumTest.getWebDriver(SeleniumTest.java:36)
at SeleniumTest.runTest(SeleniumTest.java:85)
at SeleniumTest.paint(SeleniumTest.java:23)
at sun.awt.RepaintArea.paintComponent(Unknown Source)
at sun.awt.X11.XRepaintArea.paintComponent(Unknown Source)
at sun.awt.RepaintArea.paint(Unknown Source)
at sun.awt.X11.XComponentPeer.handleEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown
Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
I have added the ‘selenium-firefox-driver-2.0a5.jar’ to my ‘archive’
attribute of Applet declaration in HTML.
Is applet capable of doing such operations ? (Since, it uses JVM, I guess it should be)
What else should I do to overcome this issue ?
Is there any work-around to start selenium from browser other than using java applets ?
PS: When I try to run the Applet alone in eclipse, it works fine. But, I get this problem when I open it in browser.
Using Signed Applets solved the issue.
Reference: http://www.developer.com/java/other/article.php/3303561/Creating-a-Trusted-Applet-with-Local-File-System-Access-Rights.htm