There’s some very old legacy code that I’m testing with Katalon Studio. Essentially, a small sample of what the code kind of looks like is this:
<script> function calcExpirationDate() { const signatureDate = new Date(document.getElementById('signatureDate').value); const expirationYear = signatureDate.getFullYear() + 3; const expirationDate = '12/31/' + expirationYear; document.getElementById('expirationDate').value = expirationDate; }</script><label>Signature Date </label><input id="signatureDate" onblur="calcExpirationDate()"/><br><label>Expiration Date </label><input id="expirationDate" />
I uploaded the code to a JSFiddle, and my Katalon script looks like this:
WebUI.openBrowser('')
WebUI.navigateToUrl('https://jsfiddle.net/djxs5ahm/')
WebUI.setText(findTestObject('Page_Edit fiddle - JSFiddle/input_signatureDate'), '1/1/2000')
WebUI.click(findTestObject('Page_Edit fiddle - JSFiddle/input_expirationDate'))
WebUI.verifyElementText(findTestObject('Page_Edit fiddle - JSFiddle/input_expirationDate'), '12/31/2003')
WebUI.closeBrowser()
However, it keeps throwing this message:
SampleTestCase FAILED because (of) Verify element text of test object 'Object Repository/Page_Edit fiddle - JSFiddle/input_expirationDate' FAILED.(Root cause: Actual text '' and expected text '12/31/2003' of test object 'Object Repository/Page_Edit fiddle - JSFiddle/input_expirationDate' are NOT matched.)
Does VerifyElementText
use the textContent
instead of the value
of an element? Is there another verification method I should use to get the element value?