我遇到以下代码的问题:
iFrame = EC.frame_to_be_available_and_switch_to_it(("MAIN_IFRAME"))
uscita = EC.presence_of_element_located((By.XPATH, "//input[contains(.,'password')]"))
uscita.send_keys('passwd')
我收到以下错误:
AttributeError: 'presence_of_element_located' object has no attribute 'send_keys'
我是新用户的Python,我希望你能帮到解决这个问题。
由于
iframe和输入的HTML:
<td style="text-align:center">
<iframe height="350" width="450" name="timb" src="timb.php" style="position: relative;top:0px"></iframe>
</td>
<td>
<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>
</tr>
<tr>
<td style="text-align:center">Password <input type="password" name="password" id="password" size="30" value=""></td>
</tr>
</tbody></table>
<input type="hidden" name="tipo" value="">
<input type="hidden" name="flag_inizio">
<input type="hidden" name="durata">
</form>
</div>
</td>
</tr>
答案 0 :(得分:1)
您需要使用<?php
$json = 'json_data'; // json data
$obj = jsondecode($json, true); // decode json as associative array
// now you can use different values as
echo $obj['json_string']; // will print page value as 'about_us.php'
for example:
$json = { "data" : [ { "contents" : "This is some content",
"selector" : "DIV.subhead"
},
{ "contents" : "some other content",
"selector" : "LI:nth-child(1) A"
}
],
"page" : "about_us.php"
}
$obj = json_decode($json, true);
/* now to print contents from data */
echo $obj['data']['contents'];
// thats all
?>
中的until
功能WebDriverWait
。它也看起来不像expected_conditions
中的字段。试试这个
iframe
顺便说一句,要切换到框架,您可以执行类似
的操作wait = WebDriverWait(driver, 10);
uscita = wait.until(EC.presence_of_element_located((By.ID, "password")))
uscita.send_keys('passwd')