Questions tagged [testng]

TestNG is a testing framework, inspired by the JUnit/NUnit unit testing frameworks. TestNG is intended to support more than just unit testing, allowing functional, end-to-end, integration, etc.

Filter by
Sorted by
Tagged with
1
vote
3answers
9k views

How to print a message after checking through TestNG's Assert.assertEquals method?

I'm getting a string value from a function. Now I want to print a message saying whether expected string and actual string are different or not. To compare these string I'm using TestNG's Assert....
1
vote
1answer
197 views

When submitting a form by fetching values from excel file it is showing Internal Server Error

When submitting a form by fetching values from excel file it is showing Internal Server Error but when I put static values in code and run it successfully submits the form without any error. Here is ...
0
votes
1answer
2k views

Getting 'nullPointerException' in @AfterMethod [closed]

Code: import java.util.concurrent.TimeUnit; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.AfterMethod; import org.testng....
2
votes
0answers
532 views

How can I make my solution thread safe for testNG parallel execution?

Background: For quite some time I have ran automated tests using forked JVM processes, this proved quite easy when injecting a driver object using spring, I could simply provide the following: @Bean(...
2
votes
4answers
3k views

Assertion message with TestNG

I use TestNG for assertion, for example with this assertTrue: Assert.assertTrue(boolean b, String s) If the assert is failed, then the String s will be printed out, and if assertion is passed, then ...
1
vote
2answers
88 views

Selenium WebDriver: Should all @Test modules connected to each other?

1. Should all automated test modules connected to each other ? Like, when I have a @Test module for Registration, after executing that module, can I connect this test to @Test Login, @Test Login to @...
1
vote
2answers
531 views

Selenium: Getting error with webElement or Webdriver “Drive” Variable

New to automation. Help is greatly needed Anybody could help me with following code Why i am getting NullPointerException? Error: Null pointer access: The variable driver can only be null at this ...
1
vote
2answers
2k views

Can't use if condition using selenium webdriver

I've got the following situation: I want to fill a field which is displayed some times and others don't. So, to solve this I used a if condition along with page objects. public static WebElement ...
0
votes
1answer
379 views

Remove tests that were not executed from Allure report

While running test I use different test-suites (xml files with list of tests to execute). E.g. I need to run smoke-tests so I choose corresponding xml with simplest tests (login/logout; selecting main ...
2
votes
3answers
3k views

How to test using one excel dataprovider in TestNG for multiple test cases

I created a testdata in Excel with multiple test cases. Ex: #UserName# #Password# #PhoneNumber# invalidUsername validPassword validPhoneNumber vaidUsername invalidPassword ...
0
votes
3answers
220 views

Cannot set Screenshots on test Listeners - selenium

I am creating TestFramework and want to set in TestListener class the method which take screenshots but during failed test the Browser closes, another browser is opened and the screenshot is created (...
1
vote
2answers
3k views

How to use dependency in TestNG with two test cases from two different classes?

How to use dependency in TestNG with two test cases from two different classes? For Example, I have two classes: package com.test.class public class A{ @Test public void testA(){ } } ...
-1
votes
1answer
267 views

How do I run multiple testcases defined in different classes with two different logins using Selenium,Java and TestNG?

Example: Public class A() { Method A1 Method A2 } Public class B() { Method B1 Method B2 } I am using dataprovider to get the login info (id and password) from excel Public class login() { User1 ...
1
vote
1answer
91 views

Working with multiple clients/languages/sites

I would like to ask what a good solution to working with clients that have different websites. My first one is how to deal with languages? Do I create separate tests? for 125 different clients? Are ...
1
vote
1answer
5k views

How to Launch multiple Chrome Browsers in Parallel using TestNG

I need to automate the two Web applications in parallel and that needs to validate in Chrome browsers. So I have two testng XML files(testng1.xml and testng2.xml), my scenario is to launch one ...
2
votes
1answer
452 views

Is there any ways to run any method or line of code after @AfterSuite in TestNG?

I am having below configuration, Maven project Execute test case through testng.xml External code to write report Here I have write code to generate reports. It depends on complete all test cases ...
1
vote
0answers
207 views

“NoSuchElementException” while executing Selenium script with TestNG

I'm trying to search few records in a website. The input data is in an excel sheet and I need to write the search result into another excel sheet. And while executing the script, the screen hangs at ...
1
vote
1answer
688 views

Multiple TestNG Reports to one Report

Currently I have 20+ Test Suite which run as individual Job in jenkins. This will generate respective testng report on the nodes that it ran (index.html). can i consolidate all the 20+ reports into ...
6
votes
2answers
186 views

Is it possible to move after and before methods to interface with Java 8?

The problem is that my test class is already implemented some class: public class MainTest extends ExecutionContext ... Thus, I can move general logic to parent class as it is usually done: public ...
1
vote
1answer
368 views

How to display multiple parameter value in excel report in TestNG

I have created test script for the upload file. In the script, I have written the code for upload different kind of file and check the result. But i have confusion about passing multiple data to the ...
2
votes
2answers
274 views

Is there any way to capture HTTP request and response in automation?

I am using TestNG framework to automate mobile application. I want to capture endpoint url.
4
votes
1answer
2k views

TestNG: Multiple suite files are not running but single xml file is running multiple times

This is my testng.xml file: <suite name="Suite1" verbose="1" parallel="true" thread-count="5"> <suite-files> <suite-file path="xml-files/live.xml"></suite-file> ...
1
vote
4answers
24k views

Cannot get a STRING value from a NUMERIC cell. How can I resolve this issue in selenium webdriver using POI?

I am trying to read data from an excel sheet and write on my application.But shows an error while trying to pass a numeric value using string. Please suggest me how can I resolve the issue. Please see ...
0
votes
3answers
1k views

NullPointerException is thrown on second method when using dependsOnMethods TestNG attribute with Selenium

package testNG; import java.util.concurrent.TimeUnit; import org.openqa.selenium.*; import org.openqa.selenium.WebDriver; import org.testng.annotations.*; public class TestNGUsingFacebook { ...
0
votes
2answers
2k views

Getting an error after execution as FAILED CONFIGURATION: @BeforeTest Login [closed]

java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/...
2
votes
1answer
970 views

Testng DataProvider parametrisation using xls

I am using testng dataprovider(using xlsx) for parametrization, I have 20 parameters for 1 method and some of these are optional so not specifying values for optional parameters. When I run my test I ...
-2
votes
2answers
635 views

How to resolve Nullpointer exception [closed]

Here is my code: General.Java: package com.hrms.lib; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.openqa....
0
votes
1answer
254 views

Is negative testing possible in TestNG?

I want to check if a site allows a user to register using the same email multiple times. I use TestNG framework. How can I do negative testing for the case below? @Test public void testRegistration() ...
3
votes
2answers
20k views

How to call a method from one class to another class when both are TestNG classes

I have 2 TestNG classes which are: ProductCanvas package objectRepo; import java.util.List; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium....
2
votes
1answer
122 views

How should I handle failing tests caused by external dependencies?

I have a situation where an dependent application is down and I cannot execute the test case. The test execution is automated. The test first calls the dependent application API and this API returns a ...
1
vote
0answers
84 views

How to extract adb dumpsys response for validation?

I need to validate few status of the android device. Can any one let me know how to extract the information from adb dumpsys and validate the responses using Java. Your help is much appreciated. Ex: '...
0
votes
1answer
1k views

Getting NullPointerException when tried to test two different pages

I am new to automation testing and I have been stuck on testing two different pages (HomePage and AboutPage) BasePage.java public class BasePage { protected WebDriver driver; public BasePage(...
4
votes
4answers
193 views

How to create test data/pre-requisites if it is required for only few of test cases of a test class?

I've clubbed feature related tests in one test class. Suppose we've 50 tests in that class. Out of 50, suppose there are 5 test cases which require common test data or pre-requisites. If I create/set ...
0
votes
1answer
324 views

How do I execute multiple test class parallely. which using same function in another class using testng

How can I execute multiple test class 'test1' and 'test2' parallely? Which is using the same function in another class using TestNG. When I define the parallel option as 'classes' and thread-count as ...
1
vote
0answers
316 views

Couldn't able to run the testng script in Maven using cucumber

Below is the TestRunner class: import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; import cucumber.api.junit.Cucumber; import cucumber.api.testng.AbstractTestNGCucumberTests; //@...
1
vote
1answer
4k views

Selenium Testng, getting error Null Pointer exception

I'm using below code using Testng, getting error Null Pointer exception: public class Login_SF { public static WebDriver driver; String text; @BeforeTest public void Login() { System....
2
votes
4answers
807 views

How to use java to access excel with selenium webdriver for data for tests

How to access excel files from selenium webdriver using Java ? I am new to selenium Webdriver, I have a scenario where I have to provide different sets of values to the different test case. Let, us ...
0
votes
1answer
494 views

Execute TestNG.xml file from Build.xml(ANT)

Below is my Build.xml file. I am trying to execute my TestNG.xml through Build.xml but I am getting the below error every time: [testng] Cannot find class in classpath: The below file is working ...
1
vote
1answer
200 views

Is throwing custom exceptions by test an anti-pattern?

Sometimes, I can see the tests written like that public void shouldDoX() throws SomeCustomException { ... I think throwing custom exceptions is an anti-pattern because it makes analysis of the test ...
1
vote
1answer
7k views

TestNG--java.lang.AssertionError: expected [5] but found [5]

My TestNG test implementation throws an error despite the expected value matches with the actual value. Here is the TestNG code: int rowCount=driver.findElements(By.xpath(prop.getProperty("xpath")))....
1
vote
2answers
290 views

How to add tolerance for time period using assert command in TestNG tool

I am doing regression testing. In my Aplication I am giving assertEquals() command for time period which is in miliseconds.But it has very small changes time period and my testcase failed.So I want to ...
0
votes
2answers
298 views

How to add the test cases to a test-suite file that calls other test suites in TestNG?

I have a testNG.xml file having the code as mentioned below.This file is calling 2 other test suite files- Suite1 and Suite2. But I want to add some test cases to this file as well. Can I do this and ...
0
votes
1answer
5k views

Getting error while configuring extent reports in selenium

BaseTest.java import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.Assert; public class BaseTest { public WebDriver driver=null; public Properties prop; public void ...
1
vote
1answer
204 views

TestNG reporting dynamic test cases

I have multiple Test Cases using a single test method dynamically. It it possible for TestNG to report the number of passed Test Cases and number of failed Test Cases? If it is possible, how do I ...
0
votes
3answers
1k views

Creating UI to run my tests

I run my test using Java, Selenium and TestNG. When I execute my test suite I have it set up where the testng.xml has all the configurations to run my tests. I am wondering, if I can set up some UI ...
1
vote
1answer
5k views

Showing NoClassDefFoundError after executing testng.xml file through command prompt

I am trying to execute a testng.XML file through the command prompt which I will use later in Jenkins with the batch file. Executed XML file gives me the following exceptions. C:\Users\Vinay\...
1
vote
1answer
576 views

How to display data in excel through data provider

@DataProvider(name = "Authentication1") public static Object[][] credentials1() { return new Object[][] { { "12234", " 6576","gfdgfdg"," dfg","gfd "}, ...
1
vote
3answers
20k views

How to pass the WebDriver instance to other Class in Selenium/Java/TestNG?

I have created 2 classes in 2 packages under one project and calling one method of class A into class B by creating object of class but it is giving me null pointer exception below is the code can any ...
0
votes
2answers
988 views

How to run only 1 annotated test method in TestNG ?

I have coded many Test Cases as Test Methods with @Test Annotation. I have used only one class for all methods. I want to run only 1 or 2 particular methods. And not run other methods. Please ...
1
vote
1answer
1k views

Why doesn't testNG assertion message get printed after each test in data-driven testing?

I am running Data-driven tests driven from a spreadsheet which are input to TestNG test Framework. In a nutshell, the framework traverses through outlook mailbox and looks for mails based on the ...