clearText() is not working properly. Field cleared but error message for mandatory field is not shown after clearing the field

Hi,
I tried clearText() for clearing the string displayed on the input field while editing a form. The field cleared. But it did not worked as expected. It was a mandatory field .Even after clearing the field able to add the form successfully(In the form only a text field and save button is present).Actually I should be able to view the mandatory error message when clearing the field and clicking on Save button.

WebUI.clearText(findTestObject(‘CategoryAdd/Page_IBOGO/input_Add Category_form-control nb ng-pristine ng-invalid ng-touched’))
WebUI.waitForElementVisible(findTestObject(‘CategoryAdd/Page_IBOGO/button_Save’), 0)

1 Like

I guess, WebUI.clearText keyword would not trigger any event to the page.

I guess, you need to give a trigger to the page to invoke its event handler JavaScript that checks the condition that “this field is mandatory”.

For example.

1 Like

If you are “waiting” for zero seconds, then get rid of the wait statement or change the timeOut to 5, or maybe even 10. On our system, it generally takes less than 0.5 seconds (which is more than 0), but it does take time.

WebUI.waitForElementVisible(findTestObject('CategoryAdd/Page_IBOGO/button_Save'), 5)

Edit: this does not mean the statement will wait a full 5 seconds, but will give you an error if the statement takes LONGER than 5 seconds. I use 10 seconds for waitFor and 2 seconds for waitForNot.

1 Like

Ok…Thanks for the update