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
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
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/
Related
I have a test project built in Intellij IDEA 2021.1 using Selenium, Cucumber and Maven
The project runs fine from within Intellij but now I want to call the tests from the command line and only those with a specific tag. Below is the project layout
There is only 1 feature file at present and I only want to call the scenarios with the "regression" tag from the command line.
I have run command line with Visual Studio/Selenium in the past but this is my first go with Java so any advice on how to get this started would be great.
try to execute following
mvn verify -Dcucumber.options="--tags not #ignore"
Or
mvn verify -Dcucumber.options="--tags #runme"
where #runme is a tag over Scenario or Feature.
you can try this command:
mvn clean install "-Dcucumber.options=--tags #yourtagName"
I am new to automation using Appium. So while using Eclipse i created a TestSuite.java file which includes all of my test cases.I want to run this file using JUnit in eclipse through command terminal.Please help me with command in mac.
I am using macOs. I am adding some screenshots of my project.
(1) This is my project in eclipse
(2) This is my TestSuite.java file
(3) Output after running
mvn surefire:test -
DrunSuite=com.appium.automation.MobileGesturesRevised/TestSuite.class
Output: output in terminal
(4) pom.xml file
pom.xml
I think I see a pom.xml in the screen shot so you can run
mvn surefire:test -DrunSuite=com.appium.automation.MobileGesturesRevised/TestSuite.class
You can just create a new run configuration for that under the Eclipse run menu.
I have my Selenium tests written in java (Eclipse). I connect to SQL Server and verify some results in database, using JDBC SQLServerDriver; The tests run perfectly in Eclipse : (Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver).newInstance();).
While I need to execute them via command line I run the following line:
mvn clean install -Dtest=Test1 test
The test gets executed only until it has to connect SQL Server to verify the data. I get error message that says:
java.sql.SQLException: No suitable driver found for jdbc:sqlserver://DBALIASSTAGING:1433
at java.sql.DriverManager.getConnection(DriverManager.java:689)
I point to JDK 1.8 in Eclipse and in my JAVA_HOME. I have my sqljdbc4.jar pointed at in Eclipse and in CLASSPATH (C:\Microsoft JDBC Driver 4.0\sqljdbc_4.0\enu\sqljdbc4.jar).
Anything else I am missing? The weird thing is the Test1 runs very well- connects and searches database within Eclipse only. But fails to connect SQL Server via command line, when I run mvn clean install -Dtest=Test1 test. The run well, but chokes when need to connect to SQL Server (11).
I have read all the posts on sqljdbc4.jar and set up the CLASSPATH variable properly and couldn't find anything wrong in my configuration.
Please give me a clue or a hint, I am totally lost, what am I doing wrong?
This is quite tricky as far as I know Microsoft has not released that jar into any maven repositories.
First of all, the fact that you have the jar in eclipse classpath means nothing for Maven (it's independent).
Maven will require you to have a dependency in the pom.xml of the project in order to use the jar. (works similarly as the eclipse classpath).
Like this:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
<scope>test</scope>
</dependency>
Notice the scope test means that the jar will only be available for maven when testing.
Now, the dependency is usually downloaded from maven central repository. Since it is not there, you will have to download it from microsoft and install it yourself using:
mvn install:install-file -Dfile=sqljdbc4.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0 -Dpackaging=jar
Missing artifact com.microsoft.sqlserver:sqljdbc4:jar:4.0
Please also check the other answer regarding JTDS. This library (it's openly available on maven) is one that I have successfully used in multiple production running software.
More info on maven dependencies: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
After some research into running Cucumber on Jenkins I have come to a dead end, I have read some post here about Running Cucumber but most are error not the process.
Running via command line the problem here is that I don't know how to call this in Jenkins after building.
I have Jenkins running on an Ubuntu server. Everything for building a maven project is setup, but how would one run the Runcukes file or setup the pom file in a way to call cucumber to start running?
Wire up a Maven task to run cucumber. As cucumber generates stubs for junit, maven's surefire plugin will run the tests nicely.
Jenkins has full support for running maven builds, so you won't have any issues there.
How to run testng.xml file from maven commands in linux command line?
I am new to automation. I have created a maven project(java) using Interlij Idea for testing a web page. I can run test groups in testng.xml using Idea.
What I need now is running those test groups from the linux command line.(running the testng xml file)
You would need to download maven on linux and then AFAIK the commands shouldn't be any different so you can use the surefire plugin in your pom and specify the suiteXmlFile param to mvn test command, something like
mvn test -DsuiteXmlFile=/src/test/resources/yourxml.xml
Hope it helps..