Integration testing with Maven, Protractor, and Selenium WebDriver

We are developing a web application using Java on the internal interface and Angular for the user interface, with Maven as the build system.

I am trying to set up automatic integration testing using Protractor, and after the Googling / StackOverflowing loads still cannot figure out how to configure the end of the second end.

Node.js / NPM installation (failure)

I tried using the frontend-maven-plugin to process Node.js and install NPM, but since we are behind the corporate firewall, it is not possible to download anything directly. It could download Node from our Artifactory, but then it was not possible to download NPM (I don’t understand why it even loads it as part of the Node package). In any case, I abandoned this idea and decided to use Node locally.

Launch Tomcat

Starting / stopping a Tomcat instance for e2e testing is done using

<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <url>${tomcat.manager.url}</url> <path>/</path> <server>Tomcat</server> </configuration> <executions> <!-- Starting Tomcat --> <execution> <id>start-tomcat</id> <phase>pre-integration-test</phase> <goals> <goal>run</goal> </goals> <configuration> <!-- Fork the process, otherwise the build will be blocked by the running Tomcat --> <fork>true</fork> <port>${tomcat.port}</port> <systemProperties> <!-- We want to use the 'e2e' profile for integration testing --> <spring.profiles.active>e2e</spring.profiles.active> </systemProperties> </configuration> </execution> <!-- Stopping Tomcat --> <execution> <id>stop-tomcat</id> <phase>post-integration-test</phase> <goals> <goal>shutdown</goal> </goals> </execution> </executions> </plugin> 

Using WebDriver (failed)

I managed to start WebDriver, but the problem is that it blocks further execution:

  <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <executions> <!-- Start webdriver --> <execution> <id>start-webdriver</id> <phase>pre-integration-test</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>webdriver-manager</executable> <arguments> <argument>start</argument> </arguments> </configuration> </execution> </executions> </plugin> 

Protractor Launch

Given that Node.js is installed and WebDriver is running, this should not be a problem. But since I was unable to start WebDriver so that it continued to run, this is blocked.

Any tips on managing WebDriver (started / stopped)?

+5
source share
1 answer

Adding directConnect: true to the Protractor configuration file solves the problem of starting / stopping WebDriver (as Nick suggested). In this case, any explicit control over WebDriver should be removed from the POM.

Available options are described in detail in the link configuration file .

+1
source

Source: https://habr.com/ru/post/1246520/


All Articles