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. 我理解的Future模式

    学而时习之,不亦说乎!                              --<论语> 什么是Future? 考虑一个场景,为了完成某个业务,我需要同时查询三张表的三条独立数据.但 ...

  2. pyinstaller打包工具简单使用

    python脚本如果在没有安装python的机器上不能运行,所以将脚本打包成exe文件将可跨平台使用,那么怎么打包了,python提供了专门的模块:pyinstaller,下面就介绍下怎么用 1.安装 ...

  3. Weblogic反序列化远程命令执行漏洞(CNVD-C-2019-48814)测试

    漏洞简介 2018年4月18日,Oracle官方发布了4月份的安全补丁更新CPU(Critical Patch Update),更新中修复了一个高危的 WebLogic 反序列化漏洞CVE-2018- ...

  4. Java - 冒泡排序的基础算法(尚学堂第七章数组)

    /** * 冒泡排序的基础算法 */ import java.util.Arrays; public class TestBubbleSort1 { public static void main(S ...

  5. 透视效果shader(边缘光)

    思路:渲染两次. 1.第一次渲染:利用Greater进行深度测试,当目标被遮挡时,用一个边缘光的效果显示. 2.第二次渲染:正常渲染. 边缘光的思路:观察方向和顶点法向量夹角越大,边缘光越明显.边缘光 ...

  6. ubuntu16.04 安装python3.6

    https://www.cnblogs.com/yjlch1016/p/8641910.html

  7. Python多线程&进程

    一.线程&进程 对于操作系统来说,一个任务就是一个进程(Process),比如打开一个浏览器就是启动一个浏览器进程,打开一个记事本就启动了一个记事本进程,打开两个记事本就启动了两个记事本进程, ...

  8. PHP面向对象的基本原则

    对象内部是高内聚的 ——对象只负责一项特定的功能(职能可大可小) ——所有对象相关的内容都封装到对象内部 高内聚就是该有的都有,用的时候不会缺胳膊少腿! 对象对外是低耦合的 ——外部世界可以看到对象的 ...

  9. CentOS 6.5中配置RabbitMQ

    先配置erlang依赖环境 yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel 安装erlang 1 ...

  10. IO流(一)字节流

    1:io流体系:对数据进行读写操作.所以IO不是读就是写咯. 2:io流的相关的类:java.io包. 有关IO的操作都会产生IOException异常 3:io:参照物是程序, i:input.进来 ...