The Alert implementation.

class selenium.webdriver.common.alert.Alert(driver)

Bases: object

Allows to work with alerts.

Use this class to interact with alert prompts. It contains methods for dismissing, accepting, inputting, and getting text from alert prompts.

Accepting / Dismissing alert prompts:

Alert(driver).accept()
Alert(driver).dismiss()

Inputting a value into an alert prompt:

name_prompt = Alert(driver) name_prompt.send_keys(“Willian Shakesphere”) name_prompt.accept()

Reading a the text of a prompt for verification:

alert_text = Alert(driver).text self.assertEqual(“Do you wish to quit?”, alert_text)
accept()

Accepts the alert available.

Usage:: Alert(driver).accept() # Confirm a alert dialog.

dismiss()

Dismisses the alert available.

send_keys(keysToSend)

Send Keys to the Alert.

Args:
  • keysToSend: The text to be sent to Alert.
text

Gets the text of the Alert.

相关文章:

  • 2022-02-25
  • 2021-09-14
  • 2021-07-27
  • 2021-08-23
  • 2021-12-06
  • 2021-06-07
  • 2021-08-03
  • 2022-02-01
猜你喜欢
  • 2021-07-05
  • 2021-11-19
  • 2022-01-03
  • 2021-09-09
  • 2022-02-14
  • 2021-12-08
  • 2021-08-16
相关资源
相似解决方案