Skip to content

Tag: testng

TestNG – how to run the same method at the end of each test

I have something like: and I would like to move Assert.assertFalse(errorsExists()) to BaseTestCase or to TestListener so I will not have to pass it every time at the end of the test. I tried to move it to TestsListener to onFinish but method errorsExists() requires driver and I have problems to get it in there. Update: I want to method

TestNG assign programatically DataProvider

If I have a method: Can I create a Listener or something in TestNG, that if I have a method: then it automatically injects specific dataProvider, without explicitly specifying it @Test(dataProvider = “webTarget”) ? Answer Ideally speaking, the easiest way to go about doing this would be to: Define an abstract class in which you define the required data provider

Batch File creation for selenium project

I need to create a .bat file to execute my selenium project that i created with TestNG. I created the .xml file: The problem is i have two @Test and for some reason he executes them as if in the same time since when he tries to login he puts the login values twice. for reference this is my .bat

How TestNG annotation from base class is executed when the Test inside the derived class is executed?

While learning TestNG on Udemy, I come across a code that I am unable to understand. The instructor has created a class named “TestBase” where he defined @BeforeMethod/@aftermethod.Later he created another class named “LoginTest” where he wrote the actual test with @test. He extended TestBase class in loginTest to get variable initiated in TestBase class. When he ran loginTest then

How to re run suite without using listener in testng

I had a requirement to re-run a complete suite from the TestNG test method itself if any of the test-case from the suite failed. Is there any way to call complete suite using an XML file or Test class within the Test method? The complete suite should re-run the after-class method or teardown test-case or last test-case @AfterClass or @AfterMethod