Reputation: 11
Please help me to run this simple example. I want to open browser through command prompt building success fully but not running in cmd (command line)
public class Hello {
WebDriver driver;
@Test
public void a() {
System.setProperty("webdriver.chrome.driver",
"C:\\Users\\PoojaPatange\\Downloads\\workfolder\\chromedrive\\chromedriver.exe");
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://ar-ae.citrusstv.com");
}
}
pom.xml file:
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.11.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.13.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
</dependency>
Please help me to run this simple example. I want to open browser through command prompt:
Images:
Upvotes: 1
Views: 1530
Reputation: 1481
Try following commands in command line to run Your tests:
0. run all testclasses inside maven project
mvn test
1. running single test:
mvn -Dtest=TestClassName#testCaseName test
2. runningalltests(in class):
mvn -Dtest=TestClassName test
3. (if using testNg) running via testsuite
mvn -Dsurefire.suiteXmlFiles=src/test/java/com/testsuites/testsuitAll.xml test
Also add in Your pom:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
</plugin>
</plugins>
</build>
Addendum to question in comment:
here is how to call one or multiple classes via testng xml file:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite">
<test name="Run">
<classes>
<class name="path.to.your.class.AND_ITS_NAME"/>
</classes>
</test>
</suite>
Hope this helps,
Upvotes: 1