0
votes

I'm trying to enter a text into a message field using Input Key. Sometimes it enters all characters and other times it gets cut off. I've tried using Press Key but it does the same thing. Is there another solution?

Example: Press Key id:noteMessage This is a note from the Robot Framework

1
Is page fully loaded? Maybe page is still being rendered or some sort of javascript running in background?JaPyR
I added a Wait Until....but maybe there is a javascript running in a background. I'll dig some more. I just didn't know what would cause this. I'm a newbie.M.C.
My assumption is that something is stealing focus. To check this add long sleep before you input text (for sure sleep is not solution, but debug tool in this situation)JaPyR
Yes, so the delay helped but, like you said, it's definitely not a solution. Do you know the best approach to getting around this?M.C.
You need to find out what is stealing the focus. Probably you have to wait until last element on the page appear (or indicator that something is running disappear)JaPyR

1 Answers

0
votes

What you could do, is insert a loop that runs for example a few times and tries each time to insert the text into the text field. During the loop you read the result of the text field, and if it matches the original text you try to input, you quit the loop.

For example something like:

${retries} = 3
${text} = "Some text that doesn't get fully displayed all the time."
${locator} = id:noteMessage
:FOR  element  IN RANGE   0            ${retries}
\     Input text          ${locator}   ${text}
\     ${inserted_text} =  Get text     ${locator}
\     ${result} =         Evaluate     ${inserted_text} = ${text}
\     Exit for loop if    ${result} = True

Of course you can insert quite a few more failsafes, but this should be a good basis. And of course you should look into the problem why the field doesn't inserted sometimes the key or text.