问题
My test is entering keys in an search text box, that's mostly ajax, and then pressing enter from the keyboard. There is no button to "start" the search so we're using the Enter key.
I'm using ChromeDriver as Firefox is not supported for our application with regards to this flow.
For my webdriver code (java), I'm having it do this:
searchIcon.click(); //opens the ajax overlay of the search text box
searchBox.clear(); //clears whatever text is already there
searchBox.sendKeys(input); //enters in the input text
searchBox.sendKeys(Keys.RETURN); //press return to start the search
The problem is, I noticed that the input text is not fully typed into the text box yet and the RETURN has already taken place. Basically, I'm doing a search of part of the input text that was entered.
Anyone encountering this? I tried to add an implicitwait before the Return action but since the elements are already loaded, that isn't going to help.
回答1:
Try this, once you enter the input into the search box, check whether the text is completely present or not inside the text box again using if statement, if complete text is present, then do the sendkeys(keys.return) part.
Just give it a try. Because once you entered the text into text box, in the next step the element obviously will be there.
Thank you, Shravan Kumar.T
回答2:
I also encountered same issue while executing my test. And it get resolved by updating webdriver to the latest version.
webdriver-manager update --versions.chrome=2.33
webdriver-manager start --versions.chrome=2.33
来源:https://stackoverflow.com/questions/24945082/webdriver-sendkeysinput-does-not-complete-before-sendkeyskeys-return