Python中Selenium处理弹框的方法

'''
对于alter弹出框,selenium不能直接定位

有三个操作
1.确定 accept
2.取消 dismiss
3.获取文本
因为alter弹出框出现在网页加载完成以后,所以implicity_wait
对他不起作用,这是依然需要time.sleep()
倒包:alt+enter,选择import time
'''
#9.关闭alter弹出框
#获取alter文本
time.sleep(2)
isSucess=derver.switch_to.alert.text
print(isSucess)
#确定
derver.switch_to.alert.accept()

猜你喜欢

转载自www.cnblogs.com/shimo/p/9848360.html
今日推荐