1

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.

4
  • 1
    What is current output? Share HTML and your current selector Commented Jan 14, 2019 at 14:19
  • Hi, Andersson, please, see the update of my original post. Commented Jan 14, 2019 at 14:24
  • 1
    I see no textarea/input element on that page. Share the code you used to open the page with search field Commented Jan 14, 2019 at 14:26
  • I updated the text just before you wrote that comment, you need to click on "Búsqueda avanzada" to see what I see. Commented Jan 14, 2019 at 14:26

1 Answer 1

3

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()
Sign up to request clarification or add additional context in comments.

3 Comments

Unfortunately, it does not "activate" the textbox for me. Maybe the xpath I send to you is wrong?
@TilHund , for me it puts the focus into search box once the checkbox "Búsqueda avanzada" is selected (try WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'cavanzada'))).click())... What is your current output? Did you get an Exception?
Fixed my issue. It was on me. I works well now. Thank you again, Anderson! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.