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
0 votes
0 answers
7 views

How to reduce execution speed by using gitlab runner

I have a GitLab repo with selenium 4 TestNG tests. They run on 4x8gb runner. It has a pipline that compiles runs sanity check, downloads drivers and then push it, for next 3 parallel jobs to download ...
0 votes
0 answers
16 views

Several test files have similar setup: How to remove duplication

I have four java classes, each containing a test. They must remain like this; I can't put the four tests in one file. Each file has a small setup portion at the top: private SQSRequestCreator ...
-2 votes
1 answer
125 views

Getting javascript error: element is not defined

I am trying to verify carousel has auto flash and manual selection options. For manual option I checked the slick dots are clickable. For auto flash option I am checking the style animate-repeate is ...
0 votes
2 answers
602 views

Loop through list of elements and perform a button click

I'm trying to loop through a list of products and identify a product with discount/promotion. if product with discount is available I want to go inside that product clicking buy now and exist for loop....
0 votes
2 answers
66 views

Stale Element Exception when looping through list of elements

I trying to loop through a list of products, identify products with discount and click on the first product with discount and and navigate to product page. While looping through for loop I get stale ...
0 votes
0 answers
28 views

How to verify the Json response field data type in rest assured test

How can we verify the Json data type of mentioned fields such as "price", "ck", "name", "enabled" and "tags" in rest assured test. { "odd":...
0 votes
0 answers
16 views

Run as testng is not found in eclipse

I have switched to a new branch and created new testng xml to run different test suite. But when I tried to run it as a testng suite eclipse only suggests run as configurations. I have set the suite ...
0 votes
1 answer
30 views

Is there any way to trigger before Method only for specific test methods

I need to prepare some data before running some test methods in my test class. But these data will be used only in 5 test methods only. The entire test class has 25 test cases. So is there any way to ...
  • 2,093
0 votes
0 answers
47 views

My TestNG BeforeMethod and AfterMethod annotations are not executing before or after the @Test annotated method

Folksm I'm using TestNG 7.5 and Selenium 4.2.2, with IntelliJ and Java 11. I've got all my bits imported and my tests will run individually, but I'm trying to get my setup and cleanup methods to work ...
0 votes
1 answer
963 views

Cannot invoke "org.openqa.selenium.SearchContext.findElement(org.openqa.selenium.By)" because "this.searchContext" is null error

I am trying to verify a functionality as a guest user and logged in user. In order to do that I log out form the system and verify the guest user actions then login again and verify logged in user ...
0 votes
1 answer
248 views

Compilation stuck at find element by xpath without giving any error

I'm trying to automate a project using selenium page object model. Below is the html code <div class="type-1 overflow-hidden card"><div class="col-xl-8 offset-xl-2">&...
0 votes
0 answers
36 views

Appium: Parallel execution halts if test is complete on one of the device

I am trying to run 2 different tests on 2 different emulators parallelly. But my execution halts on 1 device as soon as the test on other device is complete. I am using the below driver setup code ...
0 votes
1 answer
330 views

Problem finding element with text when the text contains &nbsb;

I have the following element in the DOM: <div id="sourceListDiv"> <select id="sourceList" onkeydown="uil.handleKeyDown(this)" size="15" ondblclick=&...
0 votes
0 answers
20 views

How can we get an aggregated count of all tests failing for a particular error in Report Portal?

I have multiple scripts failing for a particular assertion error. I need to get a total count of all the tests failing for that error. The logs are enabled in the Report Portal for each test. How can ...
  • 23
0 votes
1 answer
47 views

How do i get rid of duplicated local variables

I have a multiple drop-downs and need to automate them. I added the code below, how do I add them in one step? or make it easier or how do I add them in one function? I'm using eclipse and TestNG ...
-1 votes
1 answer
191 views

Custom Framework for Writing a Test that Reads a CSV File into a HashMap

I am trying to complete a lab where we are asked to write a unit test that can read a csv file into a hashmap. So far I have this: import java.io.BufferedReader; import java.io.FileReader; import java....
  • 11
0 votes
1 answer
46 views

Override Static Method for TestNg Class

Is there a way to add a screenshot in this Assert method? When my softAssert fails, I need it to take a screenshot here. Method of Assert.class : static public void fail(String message) { throw ...
  • 1
0 votes
0 answers
36 views

ScreenShot when failed not taken Selenium

I am trying to take a screenshot of the page when an exception is triggered. My main Class : @Listeners(CustomListener.class) public class AjoutPanier extends Base { @BeforeTest public void ...
0 votes
0 answers
813 views

Facing error java.lang.RuntimeException: java.lang.NoSuchMethodException: jdk.proxy2.$Proxy9.proxyClassLookup() on run appium with POM

Hi everyone im facing this error on run appium with POM here is complete error java.lang.RuntimeException: java.lang.NoSuchMethodException: jdk.proxy2.$Proxy9.proxyClassLookup() at io.appium....
2 votes
2 answers
138 views

Is it necessary to Assert web page title in every case?

I am writing a script in Selenium and TestNG to automate Add User profile pages. Now, when I land on every new page, then do I need to write Assert.equals("add user profile", driver.gettitle(...
  • 31
1 vote
0 answers
115 views

Selenium- Parallel test case using testng not working correctly. The same working fine in sequential mode

The driver instance initializes as Threadsafe. Till the launching of the browser and pass the URL everything seems to be working. But the credentials passing on anyone's browser, instead of all ...
0 votes
3 answers
128 views

When should we use Assert.true() instead of Assert.equals() method in Selenium?

What's the difference between these 2 Assert class methods?
0 votes
1 answer
108 views

Why dont we use the main() method in TestNG class?

public class Tests{ @Test public void run(){ sop("this is test method 1"); } } How will Jvm know about entry point of the program? 🤔
0 votes
1 answer
357 views

TestNG parallel execution get failed becouse im using same WebDriver on all tests

There is a situation where I have 150 test cases and I have set up Test NG parallel test execution. Unfortunately, I'm using the same web driver which initialized at the test base class on all the ...
  • 2,093
0 votes
2 answers
493 views

How can I run a login test for 100 users at the same time using Selenium, TestNG and Cucumber? [closed]

I am a newbie in Automation testing. I have a list of 100 users in a excel spreadsheet: User1: userid1/password1 User2: userid2/password2 ... and so on. I need to create a script and make all 100 ...
  • 13
0 votes
2 answers
36 views

Seeing NullPointerException on running TestNG Selenium Framework

Written the Test Script in TestNG framework where the Open browser activity is happening in "baseClass" under @BeforeTest annotation and the Test Script is written in Test Packages under as @...
0 votes
1 answer
443 views

Custom Test Case Name in TestNg HTML reports

I am trying to override the test case name in the testNg HTML report since I am using the data provider and each test data depicts something different. To do this, I added the following: I am setting ...
  • 13
0 votes
3 answers
56 views

How to have just one pre-requisite check in TestNG for multiple tests distributed across classes

I have a Test Automation project using TestNg. I want to make sure certain configurations are enabled before I start some of the tests. I have written this as a test and marked other tests as ...
1 vote
2 answers
383 views

How to automatically execute failed testing cases on Jenkins using extent report

I'm looking for a solution to execute failed test cases automatically on Jenkins. I'm currently running test cases through pom.xml which points to testng.xml I'm using extent reports to capture and ...
1 vote
1 answer
552 views

@BeforeMethod/@AfterMethod(onlyForGroups) methods did not execute, if a test method belonging to this group is executed

I am running a test suite with the test methods belonging to a certain groups. Below is the Selenium code: public class BaseClass { @BeforeMethod(onlyForGroups = {"P1"}) public void ...
0 votes
1 answer
339 views

TestNG: @BeforeMethod/@AfterMethod methods having no groups assigned are executed for the test method which have groups assigned

I am trying to run all the test methods irrespective of whether they belong to any group or not. Below is the Selenium code: public class BaseClass { @BeforeMethod(onlyForGroups = {"P1"}...
1 vote
1 answer
54 views

How to retrieve test method status and other values in IReporter implementation

I need to retrieve test method status, actual result, expected result & other attributes in IReporter implementation. Is it possible to use ITestResult to pass required data to generateReport() ...
  • 21
2 votes
2 answers
2k views

java.lang.UnsupportedClassVersionError -CucumberJvm4SMFormatter -Java runtime Version error

My testing framework is built with Cucumber, TestNG, Java 1.8 and Maven I recently updated my IntelliJ IDE Details: IDE : IntelliJ IDEA Ultimate 2020.3 - Runtime version : 11.0.9 Cucumber is ...
  • 31
1 vote
1 answer
312 views

Automated testing of Google Pub/Sub

I'm new to test automation and Google Pub/Sub. I'm developing automation scripts for regression testing. My automation framework is built with Java, Maven, Cucumber and TestNG My application is a ...
  • 31
0 votes
1 answer
2k views

Cucumber- Selenium Getting null pointer exception while openBrowser method

I am getting null pointer exception when selenium tries to launch the browser. I have already checked step Definition. Selenium OpenBrowser Method. Chrome browser version. ( I have driver 87.04 ...
2 votes
1 answer
77 views

How to debug TestNg Test Execution getting crashed due to large number of test cases

I have a test suite having 10000+ test cases, and as all these test cases run under one suite (Regression Suite), my suite getting crashed always due to very high memory consumption, maybe the size of ...
0 votes
1 answer
5k views

Maven is not running any tests called using testng suitexml files in POM.xml

I am trying to run a test using Maven by providing the testng.xml file. It is not running any test, although the build is successful. POM.xml <project xmlns="http://maven.apache.org/POM/4.0.0&...
0 votes
1 answer
1k views

Shows "[Utils] [ERROR] [Error] java.lang.NullPointerException" for data driven(excel File) API Automation test(Rest Assured)

It throws a java.lang.NullPointerException, but why it shows that, I could not find. Here is my code. ExcelUtil package Utils; import java.io.FileInputStream; import java.io.FileNotFoundException; ...
1 vote
1 answer
56 views

Fetching wrong Employee count corresponding to office location in Selenium

I am fetching Employee count according to locating using Map Highlighted No of employees count is mismatch in Image like If i search in Web table Tokyo there count is 5 but here getting 6 for ...
0 votes
1 answer
4k views

how to read the following data from excel using cucumber-java

Heading How to get the username and password from excel using cucumber package com.qa.excel; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import org.apache.poi.ss....
0 votes
1 answer
999 views

I'm using ExtentSparkReporter for generating extent reports in cucumber with testng ...how to add screenshot for failure scenarios

package cucumberhooks; import java.util.HashMap; import java.util.Map; import com.aventstack.extentreports.ExtentReports; import com.aventstack.extentreports.ExtentTest; import com.aventstack....
-1 votes
1 answer
652 views

TestNG - java.lang.NullPointerException [duplicate]

My code: package test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.testng....
  • 1
1 vote
4 answers
11k views

TestNG- No tests found. Nothing was run

UTF-8 io.rest-assured rest-assured 4.1.2 test org.testng testng 6.14.3 ...
0 votes
1 answer
625 views

Null Pointer Exception Error at Selenium TestNG

I'm trying to automate the search box but I'm getting null pointer exception. package LICT.Maven_ReCheck_Search; import java.util.concurrent.TimeUnit; import org.openqa.selenium.WebDriver; import ...
1 vote
2 answers
684 views

Passing arguments to a DataProvider method using TestNG

Given my data CSV file: jones;1293039, smith;2938949, johnson;1203939, clark;8293044 And my DataProvider: @DataProvider(name="data") public Iterator<Object[]> custDataProvider(){ ...
  • 373
0 votes
0 answers
638 views

TestNG Listener not working on XML

My testing XML is like below <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <suite name="...
  • 487
0 votes
0 answers
89 views

How to execute test cases after ide crashed

Kindly suggest if I have 100 test cases after executing 40 Test Cases my IDE was crashed. So, on the next time when I am restarting my Test Cases again the execution should be start from 41 to 100. I ...
0 votes
1 answer
719 views

How to split data passed from a .CSV file to a TestNG DataProvider

Given my .csv data file in format name:reference :- Johnson;464758, Smith;839393, Jones;940392, Davidson;182939, Arthurs;938494 And given my test code: final static String DELIMITER = ","; ...
  • 373
3 votes
0 answers
191 views

How to avoid using same data in parallel execution

This question is similar to How to manage application data when running multiple tests in parallel? But I want to know if there's a way or listener in testNG that will lock certain method when running ...
0 votes
0 answers
2k views

Not able to run my test from testng.xml file

I'm not able to run by test case from testng.xml file after run of file I'm getting that Total tests run: 0, Failures: 0, Skips: 0 but if I will try to run the test class directly then test will run. ...

1
2 3 4 5
8