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

Python 如何使用selenium在chrome中自动化此弹出窗口?,python,selenium,browser-automation,Python,Selenium,Browser Automation,在Firefox中,这个popup()是一个窗口类型的东西,而且我可以将该选项保存为默认值。但在chrome中,它是一种警告性的弹出窗口。如何使用selenium单击此弹出窗口中的按钮?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 sho

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

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() 

尝试查找您可以在python obj=driver.switch_to.alert obj.accept中尝试此操作