2017-08-30 2 views
1

私は、EclipseでSeleniumとChromedriverを使って簡単なSpock Web UIテストを実行しようとしているMaven Webプロジェクトを持っています。ファイルの実行コンフィグレーションVM引数に以下を追加すると、テストクラスを個別に実行して、 "Run As> Junit Test"を選択することができます:Spockテストでクロムドライバを起動するときに問題が発生しました

-Dwebdriver.chrome.driver =/Users/mht/ChromeDriver /2.3.1/chromedriver

明らかに、これは私のシステム上のChromedriverの場所です。次に、テストを実行するためにプロジェクトレベルでMavenビルドゴールを設定しようとしました。私はプロジェクト名をクリックし、 "Run Configurations> Maven Build"を選択し、自分のpomで定義された検証目標と一致する "Verify"設定を作成します。 「目標」ボックスでは、「確認」を入力し、JREタブでは、VM引数ボックスにchromedriverの上記の場所も入力します。この目標を実行するか、コマンドラインで「mvn verify」を実行すると、次のエラー:

geb.driver.DriverCreationException:コールバックからドライバの作成に失敗しました 'script15040527017471153797989 $ _run_closure1 @ 1046d517' com.google.common.base.Preconditions.checkState(Preconditions.java:754) で .. 。

クロムドライバをプロジェクトのベースディレクトリにコピーすると、検証の目標を使用するか、コマンドラインで「mvn verify」と入力してテストが実行されますなぜクロムドライブロケートを設定しないのですか?イオンは目標レベルで働いていませんか?

私はこれは本当に重要とは思わないが、私のポンポンのビルドセクションには、Mavenの引数はデフォルトあたりの確実かつフェイルセーフの設定に渡されません

<build> 
    <plugins> 
     <plugin> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.6</version> 
      <configuration> 
       <webXml>src/main/webapp/WEB-INF/web.xml</webXml> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-failsafe-plugin</artifactId> 
      <version>2.18</version> 
      <executions> 
       <execution> 
        <goals> 
         <goal>integration-test</goal> 
         <goal>verify</goal> 
        </goals> 
       </execution> 
      </executions> 
      <configuration> 
       <useFile>false</useFile> 
       <includes> 
        <include>**/*Spec.java</include> 
       </includes> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.tomcat.maven</groupId> 
      <artifactId>tomcat7-maven-plugin</artifactId> 
      <version>2.2</version> 
      <executions> 
       <execution> 
        <id>tomcat-run</id> 
        <goals> 
         <goal>run-war-only</goal> 
        </goals> 
        <phase>pre-integration-test</phase> 
        <configuration> 
         <port>9081</port> 
         <fork>true</fork> 
        </configuration> 
       </execution> 
       <execution> 
        <id>tomcat-shutdown</id> 
        <goals> 
         <goal>shutdown</goal> 
        </goals> 
        <phase>post-integration-test</phase> 
       </execution> 
      </executions> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.1</version> 
      <configuration> 
       <source>1.7</source> 
       <target>1.7</target> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.codehaus.gmavenplus</groupId> 
      <artifactId>gmavenplus-plugin</artifactId> 
      <version>1.4</version> 
      <executions> 
       <execution> 
        <goals> 
         <goal>compile</goal> 
         <goal>testCompile</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

    </plugins> 
</build> 

答えて

1

です。両方とも、これらの引数を取得しない新しいJVMをforkします。 argLineについては、SurefireFailsafeのドキュメントを参照してください。

だからmvn verify -DargLine="-Dwebdriver.chrome.driver=/Users/mht/ChromeDriver/2.3.1/chromedriver"が役立ちます。

ただし、適切なドライバを自動的にダウンロードするために使用できるWebDriver Extensions Maven Pluginを使用することをお勧めします。次に、単純なスクリプトを実行して、geb config経由でドライバを見つけたり、既知の相対的な場所をハードコードしたりすることができます。

ところでgmaven-plusプラグインは古くなっています。

関連する問題