Reputation: 25
I know there are alot of questions like this one, but none seems to work.
This is the code i'm using
try:
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, 'captcha_input'))
)
print("done")
except:
print("error")
There is an iframe in the page but the element im looking for isn't inside it, but I tried it anyways:
try:
iframe = driver.find_element_by_xpath("/html/body/iframe")
driver.switch_to.frame(iframe)
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, 'captcha_input'))
)
print("done")
except:
print("error")
The output of both is "error". Any ideas?
Upvotes: 2
Views: 141
Reputation: 6433
You need to add the id
property in the HTML if you want to get it by ID:
<input id="captcha_input" name="captcha_input" value="" placeholder="Please input the chars in left captcha" size="30" style="height:34px; padding:6px 12px; font-size:14px; line-height:1.428; color:#666; border:1px solid #ccc; border-radius:4px; box-shadow:inset 0 1px rgba(0,0,0,.075);">
The name
property and the id
property are not interchangeable.
Upvotes: 0
Reputation: 29362
okay you are using ID, but it's Name, so try changing that and see if that works :
try:
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.NAME, 'captcha_input'))
)
print("done")
except:
print("error")
Upvotes: 1