Validate the text you entered (set/sendkeys) before submitting form

Hello,

I am have an issue where my username and password sometimes gets truncated before clicking the login button. I have tried various means to rectify this situation by using methods such as waiting for the webpage to load, element to load, etc., but it still happens. How can if verify the text i entered is what i expect? I tried the getText method but it returns blank, and i have inspected the page source after i enter the values but it doesn’t find anything.

I would like to read the actual values in the fields and if they aren’t what i expect, then I want to loop until they are (with limit).

Thanks in advance!

Please describe exactly what you mean by “truncated” – are you saying some characters are missing?

If you can see the values entered into the page, getText should return the text without a problem.

You will not find entered text using the page source. The page source should reflect the code as supplied from the initial HTTP request to the server.

1 Like

@Russ Thomas

Thanks for responding, i have liked many of your post. Yes, I am saying that the sendkeys is not sending all the characters. This only happens intermediately, but it seems like something that should be easy to fix. I will try the getTex method again, maybe there is an inner element that I need to target.

Okay, then perhaps you are suffering from sendKeys being too fast (I seem to recall IE 11 suffered worst when I used it).

For this reason, I wrote my own using the Actions class.

https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/interactions/Actions.html

Perhaps this Stack Overflow discussion might help you: