0

java -jar selenium-server-2.1.0.jar -role rc -hub http://localhost:4444/grid/register -port 5555

2.8.2011 12:14:12 org.openqa.grid.selenium.GridLauncher main
INFO: Launching a selenium grid node
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONExceptio
n
        at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:57)
Caused by: java.lang.ClassNotFoundException: org.json.JSONException
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 1 more
4

4 に答える 4

3

必要なすべてのライブラリを取得するには、selenium-server-standalone-2.XYjar を使用する必要があります。selenium-server-2.XYjar は、独自のクラスパスを管理する場合のみです。

于 2011-08-02T12:52:17.983 に答える
1

I have the same problem. Things I've tried so far:

  1. Include the Selenium-2.3.0/libs folder in my classpath environment variable
  2. Include the Selenium-2.3.0/libs folder with a command line override "-classpath /path/libs/*"
  3. Add json.jar (with JSONException.class in org/json folder) to my jre's ext folder and made sure it's on the classpath
  4. Written my own MyTest.java class (code below), compiled it and run it without problems
    import org.json.JSONException;

    public class MyTest {
      public static void main(String[] args) {
        new JSONException("message");
      }
    }

So what's next?

于 2011-08-02T11:28:43.707 に答える
0

セレンに取り組んでいて、セレンを初めて使用する人向け。最新の Selenium Standalone Server jar ファイルをhttp://docs.seleniumhq.org/download/からダウンロード します。プロジェクトを右クリック -> ビルド パス -> ビルド パスを構成. [Add External Jars] ボタン 次に、ここからダウンロードした上記の jar ファイルを追加します。[適用] をクリックしてから [OK] をクリックします。

これで問題は解決しました。

于 2015-07-20T16:51:43.310 に答える
0

nirvdrum が述べたように、クラスパスを管理したい場合を除き、selenium standalone serverJAR ファイルを使用することをお勧めします。

ハブ用:

java -jar selenium-server-standalone-2.3.0.jar -role hub

同じマシン上のノードの場合:

java -jar selnium-server-standalone-2.3.0.jar -role remotecontrol -hub http://localhost:4444/grid/register -port [XXXX](4444 以外)

これは、グリッドのセットアップを取得するためのものです。グリッドを介してテストを実行するにはRemoteWebDriver、ハブを参照するインスタンスを使用する必要があります。例えば:

WebDriver driver = new RemoteWebDriver( new URL("http://localhost:4444/wd/hub"), DesiredCapabilities.firefox() );
于 2011-08-02T16:50:41.837 に答える