Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Selenium webdriver make a random time beween send keys (to simulate human behaviour when typing)?

I am using selenium webdriver to complete a form but would like to simulate human behaviour when typing and not auto filling with my values.

For example:

driver.find_element_by_id("Address").send_keys("Anthony Street 35th")

I would want to simulate human behavior when typing Anthony Street, with random time pauses between each key stroke.

Can this be done ?

like image 556
Alex TheWebGroup Avatar asked Feb 11 '23 02:02

Alex TheWebGroup


1 Answers

just send one letter at a time through a loop.

address = 'Anthony Street 35'
address_elem = driver.find_element_by_id("Address")
for letter in address:
    time.sleep(random.randint(1, 3))  # sleep between 1 and 3 seconds
    address_elem.send_keys(letter)
like image 173
mchant Avatar answered Feb 13 '23 14:02

mchant