Forum Discussion

barry_knapp's avatar
barry_knapp
New Contributor
10 years ago

TestExecute Playback not entering entire string when running Keys operation

Im having an issue when running tests on a VM using TestExecute



The test in quesiton is basically entering a string in a search box using the Keys operation.



Occasionally, the string i want to input in the text box is not input correctly with one character missing. This causes my test to fail as it can not find the subsequent objects for the tests that follow it.



It seems to happen roughly 5% of the time. (Yesterday i left a simple test to run where it will open the browser, enter string in search box, hit search, close and repeat. It did this 205 times, of which there were 10 failures) A 95% success rate is not bad at all, but i wonder why it is happening.



Is there a reason why this might happen?

5 Replies

  • Yeah I've found that too, always had missing characters when using Keys when working on VM's. I switched to using SetText and haven't had problems since. So if the SetText action is available for the object I would use that:



    TestObject["SetText"]("Some string");








     


  • OK, if you have to use Keys what about adding a do while loop around it so that it will keep entering the text until the searchbar text equals the string? E.g.



    do

    {

      // Clear the search box

      // Enter the string

    }

    while(// Searchbar text != the entered string)





  • Hi,



    You can either wait for an object and than do .keys or just switch to SetText.

    SetText is more reliable than .keys.

    But its always good to have a wait logic in place before performing any actions on page elements.



    -Neha
  • Thanks for your responses, but unfortunately SetText is not an option because the software i test has JQuery autofill dropdowns appear once you enter 3 or more characters in the search box.



    What we have noticed is when using SetText, the auto complete dropdown does not appear which is why we use the Keys operation.