There are the following types of bullet frames:
(1) div pseudo bullet frame
(2) win bullet frame (several processing methods)
(3) alert, confirm, prompt bullet frame
Detailed explanation:
(1) The div bullet box is embedded in the iframe, so you can directly find_element().click(), etc., such as: element >>> "search settings"
(2) win bullet box, such as uploading files.
a. If the tag type is input, such as: <input type="file" titile="upload file" name="uploadfile", etc.>, then:
driver.find_element(xxx).send_keys ("here is the file path, details to File")
b. If the tag type is not input, use a third-party library >>> pywinauto (specially deal with windows GUI):
python pywinauto can automate the PC side.
(3)alert、confirm、prompt弹框
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
</head>
<body>
<div align="center">
<h4>hello girl</h4>
<input type="button" οnclick="showPro()" value="输入框弹窗按钮"/>
<input type="button" οnclick="showAlert2()" value="提示弹窗按钮"/>
<input type="button" οnclick="showAlert()" value="确认弹窗按钮"/>
<span id="textSpan"></span>
</div>
</body>
<script>
function showAlert(){
document.getElementById("textSpan").innerHTML="";
if(confirm("你是帅哥吗?")){
document.getElementById("textSpan").innerHTML="<font style='color: red;'>您为何如此自信?</font>";
}else{
document.getElementById("textSpan").innerHTML="<font style='color: red;'>您为何如此谦虚?</font>";
}
}
function showPro(){
document.getElementById("textSpan").innerHTML="";
con = prompt("输入1为强哥聪明,输入2为左哥笨");
if(con==1){
document.getElementById("textSpan").innerHTML="<font style='color: green;'>强哥是真聪明啊</font>";
}else if(con==2){
document.getElementById("textSpan").innerHTML="<font style='color: green;'>左哥是真笨啊</font>";
}else{
document.getElementById("textSpan").innerHTML="<font style='color: red;'>您没有按要求输入,请重新输入</font>";
}
}
function showAlert2(){
document.getElementById("textSpan").innerHTML="";
alert("用我三世烟火,换你一世迷离");
}
</script>
</html>
driver.switch_to.alert() Switch to the pop-up box
driver.accept() Click to confirm
driver.dismiss() Click to cancel
driver.text() to get the text
The process of pop-up processing:
(1) Click upload, a pop-up box will appear
(2) Get the pop-up box
(3) Print the content of the pop-up box
(4)
Alert is a warning dialog box, which can only be
processed by accepting and confirming the pop-up box , which can be cancelled and accepted
Prompt box processing, can be canceled, accepted, and can enter content
Thanks for the summary of the following big guys:
https://blog.csdn.net/lykio_881210/article/details/80915882?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522161443012516780264078795%2522%252C%2522scm%2522%253A% 252220140713.130102334…%2522%257D&request_id=161443012516780264078795&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2 all sobaiduend~default-1-80915882.first_rank_v2_pc_rank_v29&utm_term=selenium+alert