摘自/sanzangTst/p/7685304.html 不是所有的弹出框都叫alert,在使用alert方法前,先要识别出到底是不是alert。先认清楚alert长什么样子,下次碰到了,就可以用对应方法解决。 alert/confirm/prompt弹出框操作主要方法有: text:获取文本值 accept() :点击"确认" dismiss() :点击"取消"或者叉掉对话框 send_keys() :输入文本值 --仅限于prompt,在alert和confirm上没有输入框
一、认识alert
HTML源码demo:<html>
<head>
<meta charset="GBK">
<title>Alert</title>
</head>
<body>
<input id = "alert" value = "alert" type = "button" onclick = "alert('您关注selenium Python吗?');"/>
<input id = "confirm" value = "confirm" type = "button" onclick = "confirm('确定关注selenium Python?');"/>
<input id = "prompt" value = "prompt" type = "button" onclick = "var name = prompt('请输入:','selenium Python'); document.write(name) "/>
</body>
</html>