Reputation: 1772
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
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
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