Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
314 views
in Technique[技术] by (71.8m points)

Selenium + Python - entering text in form with no label/id?

I"m trying to enter some text in the box as shown below. I've narrowed the element down to SMDMainText. I've tried numerous ways of finding the element, however when I try to send_keys(), the result is that I get the error "element not interactable". The issue that I'm facing is that I'm trying to find an element called <input automplete="on"> and don't quite understand how to send text to it.

element = browser.find_element_by_class_name("styledModalDialogueDIV")
element = browser.find_element_by_css_selector("form")
element = browser.find_element_by_id("SMDMain")
element = browser.find_element_by_id("SMDMainText")
element = browser.find_element_by_css_selector("input")

# comment all but 1 line above, and try below:
element.send_keys("Hello World")  # same error is produced for each try

enter image description here

question from:https://stackoverflow.com/questions/65836447/selenium-python-entering-text-in-form-with-no-label-id

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to target the input tag.

element = browser.find_element_by_css_selector("#SMDMainText>div>input")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...