Unable to execute TestNG programmatically due to difficulties in creating an executable JAR file

Looking to create an executable jar file from Selenium TestNG code.

 import org.testng.TestNG;
import com.test.Utility.ExtentReporterNG;

public class JarCreator {
    static TestNG testNg;
    public static void main(String[] args) {
        ExtentReporterNG ext = new ExtentReporterNG();
        TestNG testNg = new TestNG();
        testNg.setTestClasses(new Class[] { LoginTest.class });
        testNg.addListener(ext);
        testNg.run();
    }
}

The LoginTest class contains 3 test cases, but when executing the jar file, the following error occurs:

=============================================== Command line suite Total tests run: 3, Passes: 0, Failures: 0, Skips: 3

Configuration Failures: 1, Skips: 1

Answer №1

Update your code line :

testNg.addListener(ext);

Update to:

testNg.addListener((ITestNGListener)ext);

This modification will resolve the issue

Please keep in mind:

I am assuming that you have implemented reporting functionality in your ExtentReporterNG class which implements IReporter interface

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ways to retrieve the data from the table on this webpage

I am attempting to extract data from a table displayed on the screen in order to select rows with a status other than accepted. The code I'm using is as follows: thead = driver.find_element_by_tag_name('thead') columns = [th.text for th in t ...

Guide on transforming scraped table information into a dictionary using Python Selenium

Below is the table structure: <table class="vinInfoTable"> <tbody> <tr> <td class="caption">VIN</td> <td>W1K2052131G080816</td> </tr> <tr> <td clas ...

How can I minimize the number of polymorphic methods in my MVC design?

Currently, I am tackling a challenge in creating an MVC framework using PHP, even though my primary expertise lies in Java. I am on the lookout for a solution that aligns with OOP principles and is easily adaptable to various programming languages. Within ...

What is the method for executing a Selenium Python script on an existing tab in the Chrome browser?

Is there a way to execute the selenium python script on an already opened window instead of opening a new one every time? I'm currently using the get() method but it always opens a new window. from selenium import webdriver from selenium.webdriver.com ...

Mapping fields in Spring to JSON can be tricky, especially when dealing with fields that can be

In my object, there is a String value field which can contain either true or false. The issue arises when Spring/Jackson maps this to value: "true" as a String, causing problems with certain angularjs ng-model mappings that expect a boolean. Is there a way ...

A guide on selecting an element through find_elements_by_class_name() with the help of Selenium and Python

Here is some HTML code from a website I am trying to scrape: <div class="test-section-container"> <div> <span class="test-section-title">Section Title</span> <div style="display: inlin ...

Encountering an issue with GSON while attempting to convert an array of objects with

I'm trying to make a HTTP request using Retrofit that should return an array of objects, but unfortunately I'm encountering the following errors: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was ...

Selenium Webdriver fails to iterate through all rows in a table

Currently, I am utilizing the HTMLUnitDriver for extracting data. The table in question has rows that span across multiple pages. For instance, with 50 results, page 1 shows 24 results, followed by page 2 also showing 24 results, and then culminating with ...

Having trouble interacting with element - Selenium WebDriver is not allowing the click

I'm attempting to select the Checkout Button. This is what it looks like : https://i.stack.imgur.com/TiMEO.png And here's the HTML snippet for it : <div id="buy-button-next"> <span data-reactroot=""> <div data-cid="buy- ...

Identifying elements by their text can sometimes be tricky, especially when the text spans multiple lines. In these cases,

Can an xpath be written using the contains text function like in the following example (the code snippet below does not work)? //ul[@role='listbox']/..//span[contains(text(),'Fast-Food Restaurent')] Sample HTML Code: <span class=&qu ...

Employing Python with Selenium to programmatically click on a button with a ng-click attribute and automatically upload

I am completely new to using Python and Selenium, but I have a task that requires me to automate file uploads with Selenium. There is a button that needs to be clicked which will launch a window for selecting the file to upload. Here is the HTML code fo ...

Step-by-step guide to interact with ng-click AngularJS element through Selenium in Python

Having trouble clicking a button on a webpage that uses angularJS with ng-click. The specific page is located at: The button in question is the "Show all" button. To access the HTML, right-click on the button and select inspect. <a class="button b ...

The logger (org.apache.http.client.protocol.RequestAddCookies) is missing any appenders

While attempting to execute a Selenium Webdriver script on Firefoxdriver, I encountered an exception at runtime: log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies). log4j:WARN Please initialize the log4j ...

"Unraveling the mystery: Deserializing unidentified properties using JSON-B

Is there a way to deserialize the JSON data with dynamically generated numeric keys into a Map using Quarkus' JSON-B implementation? The challenge lies in dealing with unknown properties and mapping them to a Map<Long, MyObject> without manually ...

Upgrading from Angular 1.2.x to 1.3.x resulted in a malfunction in the rendering of a webpage by the PhantomJsDriver (GhostDriver)

Following the update of our client Angular version from 1.2.8 to 1.3.5 (or testing other 1.3.x versions), a particular web page in the SUT started failing to render completely. The error message displayed was: [ERROR - 2015-03-22T08:28:04.332Z] Session ...

Unable to extract information from ziprecruiters.com

I need help extracting job data from ziprecruiters.com to populate my database. I have been successful with indeed, but encountering issues with ziprecruiters.com class JobScrapeCommand(BaseCommand): base_url = "https://www.ziprecruiter.com/&qu ...

Execute a click action on a web element using Python's Selenium only if

Currently working with Python Selenium, my goal is to verify the visibility of an element and then proceed to click on it if visible... # Verify whether the element is visibly displayed checkElement = driver.find_element_by_xpath("//a[@id='form1& ...

Access the website using Python's Selenium module

I am attempting to use Python Selenium to log in to this website, and have written the following code: # -*- coding: utf-8 -*- from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from ...

Mapping objects with nested objects using ObjectMapper

I'm facing an issue with mapping a JSON response that contains an array. The mapping process is throwing an error, and I need help on how to handle this type of JSON structure. { "total":10, "count":10, "start":0, " ...

My PyPI installed package is unable to detect the chromedriver file

After creating a python package and publishing it in PyPI, I encountered an issue with the chromedriver selenium code. Despite adding the chromedriver file to the PyPI package folder and specifying the file path in the code as: driver_path= Path.cwd() / &q ...