Alert类的路径:from selenium.webdriver.common.alert import Alert

Alert类主要是一些对弹出框的操作,如:获取属性、确认、取消等

接口内容:

from selenium.webdriver.remote.command import Command

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

"""

def __init__(self, driver):
"""
Creates a new Alert.

:Args:
- driver: The WebDriver instance which performs user actions.
"""
self.driver = driver

@property
def text(self):
"""
Gets the text of the Alert.
属性:获取弹出框的内容
@property 表示用属性调用
"""
return self.driver.execute(Command.GET_ALERT_TEXT)["value"]

def dismiss(self):
"""
Dismisses the alert available.
不同意弹出框的内容
"""
self.driver.execute(Command.DISMISS_ALERT)

def accept(self):
"""
Accepts the alert available.
确认弹出框的内容

Usage::用法
Alert(driver).accept() # Confirm a alert dialog.
"""
self.driver.execute(Command.ACCEPT_ALERT)

def send_keys(self, keysToSend):
"""
Send Keys to the Alert.
发送内容到弹出框【适用于带输入的弹出框】

:Args:参数解释
- keysToSend: The text to be sent to Alert.
"""
self.driver.execute(Command.SET_ALERT_VALUE, {'text': keysToSend})

def authenticate(self, username, password):
"""
Send the username / password to an Authenticated dialog (like with Basic HTTP Auth).
Implicitly 'clicks ok'
发送的用户名/密码认证对话框(如基本的HTTP认证)。'点击确定'
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
"""
self.driver.execute(Command.SET_ALERT_CREDENTIALS, {'username':username, 'password':password})
self.accept()

Selenium_Python接口-Alert类的更多相关文章

  1. Myeclipse中打开接口实现类的快捷键

    Myeclipse中打开接口实现类的快捷键-----Ctrl + T Myeclipse中 Open Type快捷键-----Ctrl + Shift + T

  2. IDE:Eclipse查看接口实现类快捷键

    1.打开接口类 2.双击接口名选中 3.Ctrl+T,打开接口实现类

  3. Servlet API遍程常用接口和类

    本文主要总结Servlet  API遍程常用接口和类 Servlet API http://tomcat.apache.org/tomcat-5.5-doc/servletapi/index.html ...

  4. Spring常用的接口和类(三)

    一.CustomEditorConfigurer类 CustomEditorConfigurer可以读取实现java.beans.PropertyEditor接口的类,将字符串转为指定的类型.更方便的 ...

  5. Spring常用的接口和类(二)

    七.BeanPostProcessor接口 当需要对受管bean进行预处理时,可以新建一个实现BeanPostProcessor接口的类,并将该类配置到Spring容器中. 实现BeanPostPro ...

  6. Spring常用的接口和类(一)

    一.ApplicationContextAware接口 当一个类需要获取ApplicationContext实例时,可以让该类实现ApplicationContextAware接口.代码展示如下: p ...

  7. C#控制台基础 函数的参数是接口 实现接口的类都可以作为参数,很好用

    镇场诗: 大梦谁觉,水月中建博客.百千磨难,才知世事无常. 今持佛语,技术无量愿学.愿尽所学,铸一良心博客.------------------------------------------ 1.代 ...

  8. (转)beanUtil接口和类(有空的时候去看,到时候删除这个说明)

    Jakarta Commons项目提供了相当丰富的API,我们之前了解到的Commons Lang只是众多API的比较核心的一小部分而已.Commons下面还有相当数量的子项目,用于解决各种各样不同方 ...

  9. JAVA中的数据结构——集合类(线性表:Vector、Stack、LinkedList、set接口;键值对:Hashtable、Map接口<HashMap类、TreeMap类>)

    Java的集合可以分为两种,第一种是以数组为代表的线性表,基类是Collection:第二种是以Hashtable为代表的键值对. ... 线性表,基类是Collection: 数组类: person ...

随机推荐

  1. Ntp客户端

    function parseMsg (buffer) { if (buffer.length !== 48) return; const pkt = {}, now = new Date().getT ...

  2. PIE SDK影像坏线修复

    1.算法功能简介 坏条带的由来:2003年5月31日,Landsat-7ETM+机载扫描行校正器(SLC) 故障,导致此后获取的影像出现了数据条带丢失,严重影响了Landsat ETM遥感影像的使用. ...

  3. shell map使用

    # 定义初始化map declare -A map=([") # 输出所有key echo ${map[@]} # 输出key对应的值 "]} # 遍历map for key in ...

  4. 一个迷你的 Node.js 基于 Express 的 MVR 模式的 API工程 的分析

    1. 工程说明 该工程是基于 Express 库,编写的一个 API 查询返回的一个微型应用. API Resource 就是把 API 的内容当做网络资源去处理.工程中的路由访问也是返回 API 内 ...

  5. SpringBoot学习(一)

    一.Spring Boot Spring是JavaEE轻量级代替品.无需开发重量级的(EJB),Spring为企业级Java开发提供了一种相对简单的方法,通过依赖注入和面向切面编程,用简单的POJO对 ...

  6. 资料整理:基于node push server实现push notification

    chat example based on ionic/ socket.io/ redis https://github.com/jbavari/ionic-socket.io-redis-chat ...

  7. flyway-Maven插件-configuration节点配置详解

    <configuration> <driver>org.hsqldb.jdbcDriver</driver> <url>jdbc:hsqldb:file ...

  8. 1.8 js基础(常用方法小结)

    1.获取随机数 var rdm=function(n,m){ return parseInt(n+Math.random()*(m-n)); } 2.位数不够补0 function toDou(inu ...

  9. html锚点(mao dian)--特殊的超链接

    锚点(anchor):其实就是超链接的一种,一种特殊的超链接 普通的超链接,<a href="路径"></a> 是跳转到不同的页面 而锚点,<a hr ...

  10. 深入理解JavaScript系列(39):设计模式之适配器模式

    介绍 适配器模式(Adapter)是将一个类(对象)的接口(方法或属性)转化成客户希望的另外一个接口(方法或属性),适配器模式使得原本由于接口不兼容而不能一起工作的那些类(对象)可以一些工作.速成包装 ...