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

0 votes

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.guru99.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 11, 2020 in Software Testing by zaraaq
• 260 points
342 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

answered Nov 12, 2020 by Rajesh Popli

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

0 votes
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,870 points
213 views
0 votes
0 answers

Not able to execute unittests from pytest terminal

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

Mar 12, 2020 in Software Testing by Karthik
• 120 points
498 views
+1 vote
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
3,531 views
+1 vote
1 answer
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,520 points
5,113 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,010 points
5,842 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,890 points
3,605 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 2, 2020 in Selenium by Sri
• 3,010 points
4,349 views