从applet的HTML中运行Selenium webdrivers [英] Run selenium webdrivers from applet in HTML
问题描述
我需要从客户端调用硒,所以我想在一个静态的HTML页面运行Java小程序硒。
I need to invoke Selenium from Client Side, so I'm trying to run Selenium from a Java Applet in a static HTML page.
我在SUSE Linux环境下用firefox 3.6.12。
HTML页面看起来像这样
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>
该小程序被加载并打印信息的语句。但是,在
的webdriver的创作,我越来越在Java中除以下
控制台和它停在那里。
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)
我已经加入了硒Firefox的驱动程序,2.0a5.jar'我的'档案'
在HTML Applet的声明属性。
I have added the 'selenium-firefox-driver-2.0a5.jar' to my 'archive' attribute of Applet declaration in HTML.
时的小应用程序能够做这样的操作? (因为,它使用JVM,我想这应该是)
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 ?
有没有解决方法,开始从其他浏览器中的硒不是使用Java小程序?
Is there any work-around to start selenium from browser other than using java applets ?
PS:当我试图在Eclipse中单独运行小程序,它工作正常。但是,我得到这个问题,当我在浏览器中打开它。
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.
参考:<一href=\"http://www.developer.com/java/other/article.php/3303561/Creating-a-Trusted-Applet-with-Local-File-System-Access-Rights.htm\" rel=\"nofollow\">http://www.developer.com/java/other/article.php/3303561/Creating-a-Trusted-Applet-with-Local-File-System-Access-Rights.htm
这篇关于从applet的HTML中运行Selenium webdrivers的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!