I'm implementing Selenium (Python), but whenever I enter a send_keys("bla bla bla") the system can't handle it. It's literally bugging. The text erases himself or just keep the last part of the word. Is there any way we can make it slow down a bit without doing a foreach and waiting after each character has been entered?
Asked
Active
Viewed 408 times
-1
-
https://selenium-python.readthedocs.io/waits.html – Das_Geek Nov 12 '19 at 19:01
-
Is the element doing any sort of auto-complete/auto-search? That could be a factor. Otherwise I haven't really seen a case where `send_keys` overlaps characters itself. – r.ook Nov 12 '19 at 19:15
-
@r.ook yes, it does an auto-search. I didn't though it would have impacted the text field tho. After more testing, I'm pretty sure you're right. The only time it fails is when it's an auto-search field. – mr info Nov 12 '19 at 19:49
-
@JeffC, I've already done research on the matter, but NOTHING was on how to slow down the process. Therefore they wasn't a lot of thing to say. As for the testing, there's not much to test unfortunately. I have the answer I was looking for: it's not doable. – mr info Nov 13 '19 at 20:19
1 Answers
1
You can't slow down send_keys
but you can wait after every character. So if your code is like this:
elem = driver.find_element_by_id("element-id")
elem.send_keys("text to enter")
Instead of that, you can do:
elem = driver.find_element_by_id("element-id")
text = "text to enter"
for character in text:
elem.send_keys(character)
time.sleep(0.2) # pause for 0.2 seconds

Mert Köklü
- 2,183
- 2
- 16
- 20