Wednesday, August 8, 2018

How to pass parameters from testng.xml?

We can pass test data as parameters from testng.xml to the tests directly using TestNG Parameters feature.

To pass any parameter from testng.xml we can define "parameter" tag at suite, test and class level in testng.xml. Syntax is <parameter name="name_of_parameter", value="value_of_parameter"/>. We can add any number of parameters for a test. Please see the below screenshot.


To use the parameters in the test methods, we have to use @Parameters annotation provided by TestNG. And @Parameters annotation can be used with the methods that has @Test, @BeforeXXXX, @AfterXXXX or @Factory annotations. Inside @Parameters annotation we have to give the name of the parameters and these names must be same as what we have given in the testng.xml as shown in the below screenshot.

Tuesday, August 7, 2018

How to execute classes in parallel in TestNG?

In the previous post How to execute test methods in parallel in TestNG? we have seen executing the test cases/test methods of a class in parallel. In this post we will learn about executing the classes in parallel. A class will contain one or more test cases/test methods.

To execute the classes in parallel, we need to set parallel = "classes" in the 'suite' tag in the testng.xml file and set thread-count = "2", this count depends on our requirement. Please check the screenshot below

Class One: In the below class 'regressionSetOne.java' we have two @test methods

Wednesday, August 1, 2018

Katalon Tutorial 07: How to find TestObject at run time in Katalon Studio?

I faced a situation where, I will be getting a dynamic xpath and I need to find the object using this xpath to perform an action it.

We know how to add the objects to object repository and use them in the test case preparation, we have seen it the previous posts.

Suppose you are working on web table, which stores the employee details row wise. And your test case is to edit the employee details.

The generic xpath of the row is "//table[@id='emp-tbl']/tbody/tr", now I need to go through all the rows one by one and if any row is matching with the given employee details then get that row number and append that row number in the generic xpath to get dynamic xpath of the row as shsho below.

Java Program 5: How to reverse given string and each word of it?

Let us understand the problem with an example, suppose "Learn Core Java" is the given string then the expected output should be &...