java - 如何在 Java 和 JFrame 中使用 selenium 来阻止此错误

标签 java swing selenium jframe jnlp

我使用 java、selenium 和 JFrame 构建了一个应用程序。当我尝试在 JNLP 页面中启动它时,出现以下错误:

java.security.AccessControlException: access denied ("java.util.PropertyPermission" "com.google.appengine.runtime.environment" "read")
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
    at java.lang.System.getProperty(Unknown Source)
    at com.gargoylesoftware.htmlunit.gae.GAEUtils.isGaeMode(GAEUtils.java:35)
    at com.gargoylesoftware.htmlunit.util.URLCreator.getCreator(URLCreator.java:48)
    at com.gargoylesoftware.htmlunit.util.UrlUtils.<clinit>(UrlUtils.java:44)
    at com.gargoylesoftware.htmlunit.WebClient.<clinit>(WebClient.java:160)
    at org.openqa.selenium.htmlunit.HtmlUnitDriver.newWebClient(HtmlUnitDriver.java:296)
    at org.openqa.selenium.htmlunit.HtmlUnitDriver.createWebClient(HtmlUnitDriver.java:270)
    at org.openqa.selenium.htmlunit.HtmlUnitDriver.<init>(HtmlUnitDriver.java:136)
    at org.openqa.selenium.htmlunit.HtmlUnitDriver.<init>(HtmlUnitDriver.java:179)
    at org.openqa.selenium.htmlunit.HtmlUnitDriver.<init>(HtmlUnitDriver.java:175)
    at googlePackage.GoogleClass.<init>(GoogleClass.java:21)
    at googlePackage.GoogleClass.main(GoogleClass.java:31)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.sun.javaws.Launcher.executeApplication(Unknown Source)
    at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
    at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
    at com.sun.javaws.Launcher.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

我的 JNLP 文件

<?xml version="1.0" encoding="utf-8"?>
<jnlp
  spec="1.0+"
  codebase="http://localhost/Java/SignSelenium/GoogleScan"
  href="TwitterScan.jnlp">
  <information>
    <title>FrameDemo2</title>
    <vendor>The Java(tm) Tutorial</vendor>
    <homepage href="http://localhost/Java/index.html"/>
    <description>Frame2</description>
    <description kind="short">buttons within containers</description>
    <offline-allowed/>
  </information>
  <resources>
    <j2se version="1.6+"/>
    <jar href="GoogleScan.jar"/>
  </resources>
  <application-desc main-class="googlePackage.GoogleClass"/>
</jnlp>

我的类(class)

http://pastebin.com/sY9PHhvF

我已经签署了此 jar 中包含的所有 selenium jar 文件。

最佳答案

要执行该操作,JNLP 文件需要声明:

<security>
    <all-permissions />
</security>

Put 位于information 部分之后。

关于java - 如何在 Java 和 JFrame 中使用 selenium 来阻止此错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16365565/

相关文章:

java - XPATH 不起作用

java - Swing 客户端如何与 Java EE 后端通信?

javascript - 安装 selenium-webdriver 以使用 NodeJS + Selenium + Mocha(在 Windows 上)的理想位置是什么

java - JTable 标题不显示

java - 删除最后一个字符/行

javascript - 在 Selenium 中点击 JavaScript 按钮 - Java

python - 如果使用 PhantomJS,权限错误

java - 如何更改 Activity 中选项卡布局的位置?

javascript - java中长路径代码变短

java - 获取数据来填充 JTable netbeans