P.K.
P.K.

Reputation: 1772

how to validate if element's value is not empty in Katalon Studio

Im doing automatic test of my web page with usage of Katalon Studio. My problem is that I dont know how to validate if HTML element has none-empty value ex. "", " ".

Is there any quick tip for it?

Upvotes: 2

Views: 6202

Answers (2)

JanZ
JanZ

Reputation: 584

If you want to verify that a html-element has a specific value, you can use:

WebUI.verifyEqual(yourElement.getAttribute('value'),'')

Finding the element:

def driver = DriverFactory.getWebDriver()

WebElement elem = driver.findElement(ByTagName.tagName('theElementYouWantToFind'))

So if you want the test case to fail in case of empty value:

WebUI.verifyNotEqual(yourElement.getAttribute('value'),'')

Upvotes: 1

P.K.
P.K.

Reputation: 1772

My solution is following:

value = WebUI.getAttribute(findTestObject('Object/Repository/input_aaa'), 'value')
if (value == '') { throw new Exception('Empty value found')}

Upvotes: 2

Related Questions