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.

Dynamic xpath "//table[@id='emp-tbl']/tbody/tr[4]", if match found in fourth row.

Now we have the dynamic xpath, to click on the row first we need identify it ( we need to get the test object of the row).

To identify the object, we have to create the object "TestObject" class and then to that object we have to add properties like xpath, id, name and etc.

In the below code snippet we have the xpath and we are adding that to "TestObject" class object as property. Which means we found the test object whose xpath is given.

After adding the property we are returning the test object to perform any action further on it.

This is how we identify the test object at run time when some property is provided.

Thanks for reading!! Please comment your queries or suggestions on this post. #HappyLearning #HappyTesting #qababu


No comments:

Post a Comment

DevOps 01: What is DevOps and How it benefits organizations?

DevOps is a culture in an organization, where the development team and operations team help each other by sharing information, process and t...