I am trying to run a selenium script via .bat file. But I am getting failure in CMD. The script runs fine when ran via eclipse ( test case runs properly as testng class and as testng suite). But when i run the .bat it shows me below

C:\Users\sagar.pawaskar\Documents\eclipse-workspace\sel>set ProjectPath=C:\Users\sagar.pawaskar\Documents\eclipse-workspace\sel

C:\Users\sagar.pawaskar\Documents\eclipse-workspace\sel>echo C:\Users\sagar.pawaskar\Documents\eclipse-workspace\sel

C:\Users\sagar.pawaskar\Documents\eclipse-workspace\sel>set classpath=C:\Users\sagar.pawaskar\Documents\eclipse-workspace\sel\bin;C:\Users\sagar.pawaskar\Documents\eclipse-workspace\sel\lib\*

C:\Users\sagar.pawaskar\Documents\eclipse-workspace\sel>echo C:\Users\sagar.pawaskar\Documents\eclipse-workspace\sel\bin;C:\Users\sagar.pawaskar\Documents\eclipse-workspace\sel\lib\*

C:\Users\sagar.pawaskar\Documents\eclipse-workspace\sel>java org.testng.TestNG C:\Users\sagar.pawaskar\Documents\eclipse-workspace\sel\test1.xml

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

Press any key to continue . . .

Run.bat file contents

set ProjectPath=C:\Users\sagar.pawaskar\Documents\eclipse-workspace\sel
echo %ProjectPath%
set classpath=C:\Users\sagar.pawaskar\Documents\eclipse-workspace\sel\bin;C:\Users\sagar.pawaskar\Documents\eclipse-workspace\sel\lib\*
echo %classpath%
java org.testng.TestNG C:\Users\sagar.pawaskar\Documents\eclipse-workspace\sel\test1.xml

TestNG report shows

java.lang.NoSuchMethodError: 'com.google.common.util.concurrent.SimpleTimeLimiter com.google.common.util.concurrent.SimpleTimeLimiter.create(java.util.concurrent.ExecutorService)'
    at org.openqa.selenium.net.UrlChecker.<init>(UrlChecker.java:62)
    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:197)
    at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:188)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
    at src.NewTest.f(NewTest.java:22)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1510)
... Removed 26 stack frames

Tried my below sample testng project to run from a bat file.

package packageone;

import java.io.File;

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

public class ActionOne {
    WebDriver driver;

    public void mainone() {
        driver = new ChromeDriver();
    public void TestOne() {
    public void aftertest() {


And My testng.xml will be as shown below

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Sample" verbose="1">
    <test name="Sample Test">
            <class name="packageone.ActionOne" />

Tried with my below Command line code which have executed my testng test

java -cp "External Jar File folder path";"Bin folder path" org.testng.TestNG "testng.xml path"
  1. External Jar File folder path:This folder should contain all the jar file required for project to run.Create a lib folder in your project directory also add this in the build path under eclipse. It shouldn't contain any sub directory and a jar file into it. You can find the jar files in the folder from the image below.

enter image description here enter image description here

  1. Bin folder path: Which will be in default in your project directory like D:\Selenium files\Workspace\SQA\bin
  2. And your Testng.xml file path which will be like D:\Selenium files\Workspace\SQA\testng.xml

While running this will make successful testng run as shown in image below enter image description here

And i guess the real problem is in your bat script, you have given library file path as C:\Users\sagar.pawaskar\Documents\eclipse-workspace\sel\lib\* but you may have selenium jar file into a folder named "libs" since unzipped selenium jar file will come with this folder so the possible fix is to move the selenium jar file from this folder to your created lib folder.

This also will fix this issue

  • Thanks Mohamed. My setup is proper as you mentioned. also, my selenium jar folder is named lib. not sure why I am seeing the issue.
    – Safaee
    Jul 29 '20 at 14:19
  • Whether it has been fixed or still it is occuring? Jul 29 '20 at 14:23
  • issue is still occuring?
    – Safaee
    Jul 29 '20 at 14:27
  • Shall i know which command you have used whether command from my answer or else command which you have posted in your question Jul 29 '20 at 14:32
  • Also paste your lib directory snapshot like this i.stack.imgur.com/xl8ZZ.png Jul 29 '20 at 14:43

because of testNG plugin ,you are able to execute your scripts on your IDE

however there are three ways to execute your testNG class :

  • xmlSuite
  • run as testNG class
  • creating the object of testNG class directly

while executing it through


Please create a main class with main method ,Also please create the


please refer the below code:

public class TestNGMainClass {

public static void main(String[] args) {
    TestNG testSuite = new TestNG();
    testSuite.setTestClasses(new Class[] { Test5.class });
    testSuite.addListener(new Test5SuiteListener());
    testSuite.setDefaultSuiteName("My Test Suite");
    testSuite.setDefaultTestName("My Test");


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.