如何使用selenium在chrome中自动化此弹出窗口?

2024-09-27 21:22:44 发布

您现在位置:Python中文网/ 问答频道 /正文

在Firefox中,这个弹出窗口(screenshot of the popup)是一种窗口类型的东西,而且我能够将该选项保存为默认值。但在chrome中,它是一种警告性的弹出窗口。如何使用selenium单击此弹出窗口中的按钮


Tags: ofthe类型选项seleniumchromefirefox按钮
1条回答
网友
1楼 · 发布于 2024-09-27 21:22:44

Python警报处理

#Switch the control to the Alert window
obj = driver.switch_to.alert
#Retrieve the message on the Alert window
msg=obj.text
print ("Alert shows following message: "+ msg )
#use the accept() method to accept the alert if want to dismiss
obj.accept()

或者如果你想放弃它

obj.dismiss() 

相关问题 更多 >

    热门问题