答案 0 :(得分:0)
你可以试试这个:
driver.switch_to.alert.authenticate('cheese', 'secretGouda')
您可以在控制台或link上查看该文档。
>>> from selenium.webdriver.common.alert import Alert >>> help(Alert.authenticate) Help on method authenticate in module selenium.webdriver.common.alert: authenticate(self, username, password) unbound selenium.webdriver.common.alert.Alert method Send the username / password to an Authenticated dialog (like with Basic HTTP Auth). Implicitly 'clicks ok' Usage:: driver.switch_to.alert.authenticate('cheese', 'secretGouda') :Args: -username: string to be set in the username section of the dialog -password: string to be set in the password section of the dialog