Erjol Bane Erjol Bane - 1 year ago 124
Python Question

python selenium excpected conditions send_keys

i'm having a problem with the following code:

iFrame = EC.frame_to_be_available_and_switch_to_it(("MAIN_IFRAME"))
uscita = EC.presence_of_element_located((By.XPATH, "//input[contains(.,'password')]"))

and i'm getting the following error:

AttributeError: 'presence_of_element_located' object has no attribute 'send_keys'

i'm new Python's user and I would like your help on this problem.


HTML for iframe and input:

<td style="text-align:center">
<iframe height="350" width="450" name="timb" src="timb.php" style="position: relative;top:0px"></iframe>
<div style="position: relative;top:0px">

<form action="mnghlog6.php" method="post" target="timbri">
<input type="hidden" id="esculappio" name="escu" value="0">
<table style="position: relative;top:0px">
</div></td><td><div class="buttons" style="display:inline;text-align: left;">
</div></td></tr><tr><td><div class="buttons" style="display:inline;text-align: left;">
</div></td><td><div class="buttons" style="display:inline;text-align: left;">
</div></td></tr></tbody></table> </div>
<td style="text-align:center">Password <input type="password" name="password" id="password" size="30" value=""></td>
<input type="hidden" name="tipo" value="">
<input type="hidden" name="flag_inizio">
<input type="hidden" name="durata">

Guy Guy
Answer Source

You need to use until function from WebDriverWait with the expected_conditions. It also doesn't looks like the field is in iframe. Try this

wait = WebDriverWait(driver, 10);
uscita = wait.until(EC.presence_of_element_located((By.ID, "password")))

By the way, to switch to the frame you can do something like

iFrame = wait.until(EC.frame_to_be_available_and_switch_to_it((By.NAME, "timb")))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download