Knowledge of Java Enum ConditionType in Katalon Studio, Part 1

A crucial component of Katalon Studio that enables testers to specify precise requirements for interacting with web items is the java  ConditionType enum.

This adaptability is essential for developing solid and trustworthy automated tests. A range of condition types are available via the ConditionType enum, each with a specific function in identifying and interacting with web items.

We’ll examine the many condition types that are present in the ConditionType enum and provide real-world examples to demonstrate how to use them. You will know how to use these condition types to improve your Katalon Studio projects at the end of this post.

Condition Type Overview

CONTAINS

The CONTAINS condition type determines if a given value is present in an attribute or text content of a web element. This is very helpful for confirming that a specific string or substring is present in the content of the element.

new TestObject(“submitButton”); TestObject button;

ConditionType.CONTAINS, “//button[contains(text(), ‘Submit’)]”); button.addProperty(“xpath”);

As an example, let’s say you wish to see if the word “Submit” appears in the text of a button. The following is how you can utilize the CONTAINS condition type:

In this case, Katalon Studio will search for a button element with the term “Submit” in its text.

ENDS_WITH

FINISHES_WITH

If an attribute or text content of a web element terminates with a specific value, it can be confirmed using the ENDS_WITH condition type. This is helpful for examining particular suffixes within the content of an element.

Example: You can use the ENDS_WITH condition type to determine whether the URL of a link ends in.pdf format:

new TestObject(“pdfLink”); TestObject link;

“href”, ConditionType.ENDS_WITH, “.pdf”); link.addProperty;

In this case, link elements whose href attribute ends with will be recognized by Katalon Studio.pdf.

EQUALS

The EQUALS condition type is employed to verify if a web element’s attribute or text content exactly matches a specific value. This is useful for precise match comparisons.

Example: To check if a text input field’s value is exactly “John Doe”, use the EQUALS condition type:

TestObject nameField = new TestObject("nameInput");

nameField.addProperty("value", ConditionType.EQUALS, "John Doe");

In this scenario, Katalon Studio will search for an input field whose value attribute is exactly “John Doe”.

EXPRESSION

When a web element’s attribute or text content needs to be confirmed to match a given value exactly, the EQUALS condition type is utilized. This is helpful for comparing exact matches.

Example: Use the EQUALS condition type to see if the value entered in a text input field is exactly “John Doe”:

new TestObject(“nameInput”); TestObject nameField;

nameField.addProperty(“value”, “John Doe”, ConditionType.EQUALS);

Katalon Studio will look for an input field in this case whose value attribute contains the precise phrase “John Doe.”

Practical Examples

Let’s examine more in-depth real-world examples that illustrate the application of these condition types to circumstances in order to reinforce your comprehension. java, online java compiler, java online compiler,java interview questions,
java compiler online, inheritance in java

 

Scenario 1: Verify Login Button Presence

Let’s say you need to confirm that a login button with the word “Login” is present on a login page you are testing.

LoginButton TestObject = new TestObject(“loginButton”);

“//button[contains(text(), ‘Login’)]”); loginButton.addProperty(“xpath”, ConditionType.CONTAINS, “”);

LoginButton = 10; WebUI.verifyElementPresent(1);

Scenario 2: Check File Download Link

You need to verify that a download link for a PDF file is correctly displayed on a page.

TestObject pdfDownloadLink = new TestObject("pdfDownloadLink");

pdfDownloadLink.addProperty("href", ConditionType.ENDS_WITH, ".pdf");

WebUI.verifyElementPresent(pdfDownloadLink, 10);

 

Best Practices

Take into consideration the following best practices to get the most out of Katalon Studio’s ConditionType enum:

Employ Descriptive Names: Give your TestObject instances names that accurately represent their functions.
Combine Conditions: To improve element identification, use a variety of characteristics and condition types.
Validate Often: Make sure condition types are implemented correctly by regularly validating your tests.
Optimize Performance: Steer clear of extremely complicated expressions that could affect how well tests execute.
Record the Tests You Take: To facilitate future maintenance, provide remarks and documentation for complex condition categories.

Conclusion

A flexible collection of preset condition types are available in Katalon Studio’s ConditionType enum, which greatly improves your ability to construct criteria for recognizing and interacting with web items. You can write more reliable and adaptable automated tests by being aware of and skillfully applying these condition kinds.

you may be interested in this blog here:- 

SAP Leonardo Machine Learning Services
Enhance Learning With UKG Hindi Worksheet With Answers

Data Analytics and Business Intelligence