java, online java compiler, java online compiler,java interview questions, java compiler online, inheritance in java

Knowledge of Java Enum ConditionType in Katalon Studio, Part II

We will examine the other Java condition types that are present in the ConditionType enum in this follow-up blog. Gaining an understanding

of these extra condition types will help you write more reliable and adaptable Katalon Studio test automation scripts.To ensure the dependability and precision of your automated tests, each condition type fulfills a distinct function in the definition of criteria for recognizing and interacting with web items.

ConditionType Overview

MATCHES_REGEX

A web element’s attribute or text content is checked to see if it matches a certain regular expression pattern using the MATCHES_REGEX condition type. This is comparable to the EXPRESSION condition type, except instead of writing a new expression, you can use a pre-defined regular expression.

Example: The MATCHES_REGEX condition type can be used to determine whether the value of a text input field corresponds to a phone number format.

TestObject mobileTestObject(“phoneInput”) = new Field;

“^\\d{3}-\\d{3}-\\d{4}$”); phoneField.addProperty(“value”, ConditionType.MATCHES_REGEX);

In this instance, Katalon Studio will check to see if the value in the phone input field corresponds to the pattern XXX-XXX-XXXX.

.

NOT_CONTAIN

The inverse of the CONTAINS condition type is the NOT_CONTAIN condition type. It verifies whether an attribute or text passage in a web element is devoid of a particular value.

Example: Use the NOT_CONTAIN condition type to make sure the word “Cancel” is not present in the text of a button.

new TestObject(“submitButton”); TestObject button;

“text”, ConditionType.NOT_CONTAIN, “Cancel”); button.addProperty(“text”);

In this instance, buttons whose text does not contain the term “Cancel” will be recognized by Katalon Studio.

NOT_EQUAL

The inverse of the EQUALS condition type is the NOT_EQUAL condition type. It determines whether the text content or an attribute of a web element does not precisely match a given value.

Example: Use the NOT_EQUAL condition type to confirm that the value entered in a text input field is not “John Doe”:

new TestObject(“nameInput”); TestObject nameField;

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

In this case, java Katalon Studio will make sure that “John Doe” is not the value entered in the input field.

 

NOT_MATCH_REGEX

The NOT_MATCH_REGEX condition type is the opposite of the MATCHES_REGEX condition type. It checks if a web element’s attribute or text content does not match a specific regular expression pattern.

Example: To ensure that a text input field’s value does not match a phone number format, use the NOT_MATCH_REGEX condition type:

TestObject phoneField = new TestObject("phoneInput");

phoneField.addProperty("value", ConditionType.NOT_MATCH_REGEX, "^\\d{3}-\\d{3}-\\d{4}$");

Here, Katalon Studio will verify that the phone input field’s value does not match the pattern XXX-XXX-XXXX.

 

STARTS_WITH

The STARTS_WITH condition type determines if the text content or attribute of a web element begins with a particular value. This can be helpful in confirming that the content of an element has a particular prefix.

Example: Use the STARTS_WITH condition type to determine whether the URL of a link begins with “https://.”

new TestObject(“websiteLink”); TestObject link;

“href”, ConditionType.STARTS_WITH, “https://”); link.addProperty;

Katalon Studio will recognize link components in this example whose href attribute begins with “https://.”

Practical Examples

Now let’s look at some thorough real-world examples that show you how to apply these java condition types.

First Scenario: Verify Format of Phone NumberVerifying that a phone number input field is formatted as XXX-XXX-XXXX is required.

TestObject new Field = mobileTestObject(“phoneInput”);

“^\\d{3}-\\d{3}-\\d{4}$”); phoneField.addProperty(“value”, ConditionType.MATCHES INDEX);

WebUI.verifyElementPresent; PhoneField, 10;

Scenario 2: Ensure Button Text Excludes Specific Word

To ensure that a button’s text does not contain the word “Cancel”, use the NOT_CONTAIN condition type.

TestObject button = new TestObject("submitButton");

button.addProperty("text", ConditionType.NOT_CONTAIN, "Cancel");

WebUI.verifyElementPresent(button, 10);

 

Scenario 3: Verify Non-Matching Input Value

To check that a text input field’s value is not “John Doe”, use the NOT_EQUAL condition type.

TestObject nameField = new TestObject("nameInput");

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

WebUI.verifyElementPresent(nameField, 10);

 

Scenario 4: Validate Non-Matching Pattern

Ensure that a text input field’s value does not match a specific phone number pattern.

TestObject phoneField = new TestObject("phoneInput");

phoneField.addProperty("value", ConditionType.NOT_MATCH_REGEX, "^\\d{3}-\\d{3}-\\d{4}$");

WebUI.verifyElementPresent(phoneField, 10);

 

Scenario 5: Check URL Prefix

Use the STARTS_WITH condition type to confirm if a link’s URL begins with “https://”.

new TestObject(“websiteLink”); TestObject link;

“href”, ConditionType.STARTS_WITH, “https://”); link.addProperty;

VerifyElementPresent(WebUI.link, 10)

 Best Practices

The following guidelines will help you get the most out of Katalon Studio’s ConditionType enum:

  • Unambiguous Naming: Give your TestObject objects meaningful names that correspond to 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.
    Test Documentation: To facilitate future maintenance, include remarks and documentation for complex condition types.

Conclusion

java Even more flexibility and precision in creating criteria for detecting and interacting with web components is possible with Katalon Studio’s additional ConditionType choices. You may write more dependable and strong automated tests by being aware of and skillfully applying these condition kinds.

you may be interested in this blog here:- 

SAP SAC: Revolutionizing Data Analytics and Business Intelligence 

Embracing Collaboration And Growth: The UKG Community 

SAP Fiori App Customization
Scroll to Top
Call Now Button