Til Hund
Til Hund

Reputation: 1683

Selenium and python3 activate textbox without entering a value

Writing a script with selenium and python3, is there a possibility to have the script click on a textbox on the http://digesto.asamblea.gob.ni/consultas/coleccion/ (click on "Búsqueda avanzada") without entering a value, so that the cursor is active in that textbox (indicated normally by a blinking vertical line), see example picture?

enter image description here

Usually one would use

driver.find_elements_by_xpath('//*[@id="txtCaptcha"]').click()

but this does not give the desired outcome as the textbox is not "active" looking like this:

enter image description here

My idea is to have the script "activate" the textbox and wait for me to insert a captcha, so that I simply can start writing instead of click in the textbox each time myself.

Upvotes: 1

Views: 86

Answers (1)

Andersson
Andersson

Reputation: 52695

You can wait for element to be clickable and then click it:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'txtCaptcha'))).click()

Upvotes: 3

Related Questions