How do I run a selenium test using maven from the command line?

0
0

I currently use Eclipse as my Java IDE and I use Maven. I click the run button and it is able to run a Selenium Java test I wrote.

I then proceeded to install Maven on my local machine.

After going to the directory where my pom.xml file is located.
I run the command: mvn test

I receive the following results:

[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBu
ilder
with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SeleniumWebDriver 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ SeleniumWebDriver ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platfo
rm dependent
!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ SeleniumWebDriver ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ SeleniumWebDriver ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platfo
rm dependent
!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ SeleniumWebDriver ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ SeleniumWebDriver ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.139 s
[INFO] Finished at: 2014-03-17T14:12:27-05:00
[INFO] Final Memory: 12M/99M
[INFO] ------------------------------------------------------------------------

I do not understand why the Firefox webbrowser does not start, and a test is ran. When running the same test in the Eclipse IDE the Firefox webBrowser does start.

It seems to compile fine, but it is for some reason not testing or kicking off the browser when it has the .class files after compilation.

here is a copy of my pom.xml file:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>SeleniumWebDriver</groupId>
<artifactId>SeleniumWebDriver</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.40.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.40.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.40.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
</dependencies>
</project>
  • You must to post comments
0
0

This is a older thread, but still want to provide input for those who are stuck up at this. You have to make sure that the class file names you are creating are ending with “Test” string.
e.g. AppTest, TempTest are all valid class file names, but AppCheck, TempTest1 are invalid name; maven will not detect these files for execution.

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website