0

I am able to run my test cases through Eclipse IDE. It is not working when I try to run them through the command prompt/terminal.I get the following error.I have attached the screenshot below.

Please help me on this issue.Quick response will be of great help.Test Image

  • Looks like a dependency issue, please add the error as actual text instead of a picture and include in the command you use to run this from terminal. – t0mppa Sep 29 '16 at 01:42
  • This is the error I get-javac dm_login_pass.java dm_login_pass.java:3: error: package org.testng.annotations does not exist import org.testng.annotations.Test; ^ dm_login_pass.java:5: error: package org.openqa.selenium does not exist import org.openqa.selenium.By; ^ dm_login_pass.java:7: error: package org.openqa.selenium does not exist import org.openqa.selenium.WebDriver; ^ command- javac -classpath selenium-server-standalone-2.48.0.jar dm_login_pass.java – Dishant Sep 29 '16 at 02:01
  • Please edit this information in your question, as it's very difficult to read from comments. Also, is using a build tool like Maven an option or will you want a purely manual dependency management solution? – t0mppa Sep 29 '16 at 05:00
  • check this: http://stackoverflow.com/questions/33701682/how-to-properly-set-up-java-selenium-configuration-to-run-automated-tests – MissFiona Sep 29 '16 at 06:57

2 Answers2

1

You can use maven selenium plugin to run all the integration test by using selenium

In pom.xml, add this dependency

<dependency>
  <groupid>org.seleniumhq.selenium</groupid>
  <artifactid>selenium-java</artifactid>
  <version>2.25.0</version>
</dependency>

And in commandline, execute the test via maven

mvn clean test -Dwebdriver.base.url=http://www.example.com
Tue Dang
  • 41
  • 1
  • 3
  • Hi Dang.When I compile the files again I get this error: --- maven-compiler-plugin:2.0.2:testCompile (default-testCompile) @ selenium_mvn_drivermile --- [INFO] No sources to compile [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ selenium_mvn_drivermile --- [INFO] No tests to run. Please note:- The build is successful. Please guide as what should I do.This is strange. – Dishant Sep 29 '16 at 08:12
  • Hi @Dishant, I think you might not follow the maven structure, please access to maven home page for more information. - Here is one example, hopefully it could help you to investigate your issue [github-example-link](https://github.com/tuedang/springmvc-selenium-integration-test) - To run the selenium test: mvn clean install -DbaseUrl=http://localhost:9090/spring-selenium-integration-test – Tue Dang Oct 04 '16 at 03:26
0

You can run your scripts thru command prompt using Apache Ant. It uses build.xml which runs your testng.xml. Just the difference is that you run it from command prompt and not from eclipse or any other IDE. You can find more info on Apache Ant & build.xml from - http://ant.apache.org/