I am using the get text property for SSN number in the application which I am automating currently. The SSN number is hid in the form xxx-xx-xxxx with a show icon beside it. When I click on the show icon the SSN is revealed 333-44-5555 where the click doesn’t load the entire page. Only the SSN is loaded by using ajax call. SO, when I am using the webui.gettext of that SSN after clicking on the icon the text captured is xxx-xx-xxxx. I am using only xpath as the SSN object property. How do I solve this?
this should work in your case.
HTML element is defined as this:
<button type="button" id="myBtn" onclick="document.getElementById('myBtn').innerHTML = '123-456-789';">xxx-xxx-xxx</button>
Basically it changes a value after click.
And following test code works in such a case:
TestObject toHidden = new TestObject().addProperty('xpath', ConditionType.EQUALS, '//button[@id="myBtn" and text()="xxx-xxx-xxx"]') TestObject toRevealed = new TestObject().addProperty('xpath', ConditionType.EQUALS, '//button[@id="myBtn"]') WebUI.click(toHidden) WebUI.waitForElementNotPresent(toHidden, 10) println WebUI.getText(toRevealed)
Thanks for the Reply.
This is the html which I have
However, i used webui.delay(2) in my code which worked.
SSN = WebUI.getText(findTestObject(‘SSNOrder’))
WebUI.verifyMatch(‘333-44-5556’, SSN, false)