Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to wait until text input was 4 character in python 3 and selenium webdriver

I using python 3 and web scraping via selenium

I want when I type captcha character in input text after 5 character automatic click on login button

I using a code look like this:

driver.find_element_by_id("Username").send_keys('user')

driver.find_element_by_id("Password").send_keys('pwd')

## driver.find_element_by_id("login_captcha").send_keys(captcha)  Here I typing capctha with hand and I dont want using code

WebDriverWait(driver, 10).until()  # Here I dont' know how can waiting until I fixed 5 character it doing to next line

driver.find_element_by_name("button").click()

but I don't know how can check do it !

like image 219
Rai Rz Avatar asked Oct 15 '25 22:10

Rai Rz


1 Answers

Assuming mentioned input field looks like

<input id="login_captcha>

You can try below code to wait until 5 characters entered in input field:

WebDriverWait(driver, 10).until(lambda driver: len(driver.find_element_by_id("login_captcha").get_attribute("value")) == 5)
like image 114
Andersson Avatar answered Oct 18 '25 10:10

Andersson