TestNG from command line - chrome starts successfully but nothing happens after that

+1 vote

Hi,

I'm trying to run testng from command line. This is a simple test to open a web page. This will run in eclipse successfully. Please help me, I'm mew to this. I've been working on this for more than a week now, I've read every single post that shows under search for "Testng command". Those people have different problem than what I'm facing. I'm not having main class not found error, I don't see any error but failure is 1.

Starting ChromeDriver 85.0.4183.87 (cd6713ebf92fa1cacc0f1a598df280093af0c5d7-refs/branch-heads/4183@{#1689}) on port 26927 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully.

===============================================
Suite
Total tests run: 1, Passes: 0, Failures: 1, Skips: 0
=============================================== 

C:\Eclipse\WorkSpace\TestingJenkins>set classpath=C:\Eclipse\lib*;C:\Eclipse\Drivers*;C:\Program Files\Java\jdk-14*;C:\Eclipse\WorkSpace\TestingJenkins\bin

C:\Eclipse\WorkSpace\TestingJenkins>java org.testng.TestNG testng.xml

package Package1;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;

public class Test1 
{
  @Test
  public void f() 
  {
  
    Sttring baseUrl = "http://demo.example.com/test/delete_customer.php";    
        String driverPath = "C:\\Eclipse\\Drivers\\Chromedriver.exe";
    WebDriver driver;
     
    System.setProperty("webdriver.chrome.driver", driverPath);
    driver = new ChromeDriver();
    driver.get(baseUrl);
    driver.manage().window().maximize();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
                       
    driver.quit();
     
    System.out.println("///////////////////////////////////////////////////////////////////////");
  
 
  }
}



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Suite">
  <test thread-count="5" name="Test">
    <classes>
      <class name="Package1.Test1"/>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->
Nov 12, 2020 in Software Testing by zaraaq
• 270 points
2,868 views

1 answer to this question.

0 votes

Hi. @Zaraaq,

I was facing the same issue and I noticed that all of my jar files were in different subfolders. Move all of them in one library folder and execute it with the same command.

java -cp "%projectLocation%/Library/*";"%projectLocation%/target/classes/" org.testng.TestNG testng.xml

Hope this helps!

Go for Manual testing certification and become certified.

Thanks!

answered Nov 12, 2020 by Rajesh Popli

edited Jun 23, 2023 by Khan Sarfaraz

So I tried what you proposed but I'm still getting same error.  Either I'm missing a jar file that I don't know or something else. 

All my jar files are under lib folder with no sub folders now.

C:\Eclipse\WorkSpace\TestingJenkins\src\Package1 has the Test.java

C:\Eclipse\WorkSpace\TestingJenkins\bin\Package1 has the Test.class

Do I need to move the .java and .class to lib also?

Thanks

@zaraaq,

There is a minor bug in your code block. When you are using TestNG and writing methods within @Test annotation, we should define the methods with proper return types. I have used your own code and simply added the return type as void as follows:

import org.testng.Assert;
import org.testng.annotations.Test;

public class Q45191867_Assert_Pass_Suite 
{

    @Test   
    public void TC002_CheckAssert() 
    {
        System.out.println("ajkcbh");
        try
        {
            Assert.assertEquals("Pass", "Pass");
        }
        catch(Exception e)
        {
            System.out.println("Exception:"+e.getLocalizedMessage());
        }
    }

Thank you so much for the quick reply.  I do have the void, do you  mean to say I should have try and catch?

 @Test
  public void f() 
  

Thanks

Related Questions In Software Testing

+1 vote
1 answer

Console window Output Does not exist after update Chrome Version Update

Hello, @Boopathy, Regarding your query, There can be ...READ MORE

answered Nov 26, 2020 in Software Testing by Gitika
• 65,770 points
1,015 views
+1 vote
0 answers

Not able to execute unittests from pytest terminal

Hi All, I was able to execute the ...READ MORE

Mar 13, 2020 in Software Testing by Karthik
• 130 points
1,294 views
+2 votes
2 answers

How to read data in Robot framework from excel file.

You can try run "py –m pip ...READ MORE

answered May 19, 2020 in Software Testing by anonymous
8,814 views
+2 votes
1 answer

Even after providing proper xpath for element on mobile applcation,it is not able to click on the button??

You could probably try using WebDriver driver; ...READ MORE

answered May 8, 2020 in Software Testing by Kim
1,507 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,670 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,140 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,219 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,872 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP