码迷,mamicode.com
首页 > Windows程序 > 详细

WebDriver API——第4部分Alerts

时间:2015-04-29 23:04:21      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:

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.

WebDriver API——第4部分Alerts

标签:

原文地址:http://www.cnblogs.com/hushaojun/p/4467475.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!