1

I am trying to test if a validation error shows up when the user types a number into a number field that is not a whole number. The error appears when I type it into the field manually, but when I run it in selenium, the js is never triggered so the error doesn't show on the screen and the test fails.

<tr>
    <td>type</td>
    <td>//*[@id='notificationTimerNum']</td>
    <td></td>
</tr>
<tr>
    <td>sendKeys</td>
    <td>//*[@id='notificationTimerNum']</td>
    <td>1.5</td>
</tr>
<tr>
    <td>waitForVisible</td>
    <td>//*[contains(@class, 'control-error')]//*[contains(., 'The number of minutes must be entered as a whole number')]</td>
    <td></td>

I have also tried using the fireEvent command as suggested here with no luck.

In addition, I am unable to run Selenium IDE sendKeys on my local browser outside of the test environment because it errors out on sendKeys when trying to type a value into the number field.

[error] Unexpected Exception: Error: Cannot set the selection end. 
1
  • Could you share a link to the web page (or a page with similar behaviour) please? Commented Feb 25, 2017 at 7:35

1 Answer 1

2

I've experienced the same issue, in some cases, you have to send a keypress to the field AFTER you've entered the text, so after your sendKeys command with the number, do another one right after to send either a tab or enter keypress.

sendKeys | //*[id=notificationTimerNum] | ${KEY_TAB} (or ${KEY_ENTER})

For me, that "triggers" the validation of the data in the field, and you can then do the waitForVisible for the error message.

Klendathu

Sign up to request clarification or add additional context in comments.

1 Comment

In Java, sendKeys(Keys.ENTER) worked for me. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.