1

まず、ローカル webapp を開始します。

次に、Eclipse で次のテストを JUnit テストとして実行すると (with -Dbrowser=phantomjs):

@Test
public void homepageShowsSearchBox() throws Exception {
    open("http://localhost:8080/app/");
    $(By.cssSelector("#someSelector")).should(exist);
}

テストは決して終わらない。ぶら下がっているようなものです。(ブラウザで同じURLを開くとwebappが表示されます)

これはコンソール出力です:

Feb 17, 2015 3:28:59 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: executable: C:\Users\xx\AppData\Roaming\npm\phantomjs
Feb 17, 2015 3:28:59 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: port: 14234
Feb 17, 2015 3:28:59 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: arguments: [--webdriver=14234, --webdriver-logfile=D:\Test Projects\demoapp-source\web\phantomjsdriver.log]
Feb 17, 2015 3:28:59 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: environment: {}

また、ありませんphantomjsdriver.log(ログに記載されているもの)。

有用な場合、これらは依存関係です。

<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.12</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>com.codeborne</groupId>
  <artifactId>selenide</artifactId>
  <version>2.16</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>com.github.detro</groupId>
  <artifactId>phantomjsdriver</artifactId>
  <version>1.2.0</version>
  <scope>test</scope>
</dependency>
4

1 に答える 1

3

解決しました、ただ

1) 依存関係を変更します (参照):

    <dependency>
        <groupId>com.codeborne</groupId>
        <artifactId>phantomjsdriver</artifactId>
        <version>1.2.1</version>
        <scope>test</scope>
    </dependency>

2) npmでインストールしたPhantomJSは使わず、サイトからダウンロードしてパラメータとして追加する-Dphantomjs.binary.path="C:\bin\phantomjs-2.0.0-windows\bin\phantomjs.exe"(参考)

于 2015-02-17T15:15:03.933 に答える