当前位置:网站首页>Selenium的各类API方法
Selenium的各类API方法
2022-06-29 18:29:00 【是乔乔啊】
文章目录
WebDriver介绍
WebDriver提供很多与浏览器交互的功能和设置。可以通过WebDriver的功能和方法实现与浏览器窗口、警告、框架和弹出窗口的交互。同时也提供了自动化操作浏览器导航栏、设置cookie、截屏等方便测试的特性。
WebDriver功能

WebDriver方法
WebDriver通过方法实现与浏览器窗口、网页和页面元素的交互。



WebElement接口
WebElement可以实现与网站页面元素的交互。包括文本框、文本域、按钮、单选框、多选框、表格、行、列和div等。
WebElement提供了一些功能、属性和方法实现与页面元素的交互。
WebElement功能
| 功能 | 描述 | 实例 |
|---|---|---|
| size | 获取元素的大小 | element.szie |
| tag_name | 获取元素的HTML标签名称 | element.tag_name |
| text | 获取元素的文本值 | element.text |
WebElement方法


Select
WebDriver提供了特定的Select类实现与网页上的列表和下拉菜单的交互。
Select类就是Selenium用于列表和下拉菜单交互的特定类。
Select功能

select方法


Alert
Alert介绍
Alert类可以 操控javaScript警告。Alert包含的方法有接受、驳回、输入和获取警告的文本。
Alert功能

Alert方法

def test_compare_products_removal_alert(self):
alert=self.driver.switch_to_alert()
alert_text=alert.text
self.assertEqual("Are you sure you would like to remove all products from your comparison?", alert_text)
# click on Ok button
alert.accept()
def tearDown(self):
self.driver.quit()
浏览器自动化操作
WebDriver 类提供了以下方法来操控浏览器的后退、前进和刷新等操作。

边栏推荐
- 2. 在STM32CubeMX建立的Keil5工程中添加自定义的相关文件
- [how the network is connected] Chapter 3 explores hubs, switches and routers
- AMAZING PANDAVERSE:META”无国界,来2.0新征程激活时髦属性
- Error building SqlSession问题
- Redis (I) -- getting started with redis (2) -- redis data type
- 面霸篇:MySQL六十六问,两万字+五十图详解!
- mysql -connector/j驱动下载
- Sister Juan takes you to learn database -- 5-day sprint Day1
- Chapter 02_ MySQL data directory
- Hello, do you have any official website samples for MySQL CDC, PostgreSQL CDC? Give me a link to learn
猜你喜欢

Machine learning 8-artificial neural network

Shandong University project training (VII) add navigation bar to select city

山东大学项目实训(七)添加导航栏选择城市

C Primer Plus Chapter 12_ Storage categories, links, and memory management_ Codes and exercises

RocketMQ的tag过滤和sql过滤

These advantages of the Institute are really fragrant! The landing rate is still very high!

2. how to install MySQL database in Galaxy Kirin offline mode

Apache InLong百万亿级数据流处理

1. 使用STM32CubeMX建立STM32G030C8T6项目工程

山东大学项目实训(六)点击事件展示折线图
随机推荐
Data analysis time series prediction
JDBC knowledge
curl下载示例
踩坑记:JSON.parse和JSON.stringify
Source code installation mavros
Adobe Premiere foundation - opacity (mixed mode) (XII)
Sister Juan takes you to learn database -- 5-day dash day4
Anaconda installs and configures jupyter notebook remote
面试题 10.10. 数字流的秩
MySQL -connector/j driver download
Shell basic syntax -- process control
js将秒转换成“2h30min50s”的格式
The table ‘table_name‘ is full 异常排查及解决方案
Sd6.25 summary of intensive training
【TcaplusDB知识库】TcaplusDB单据受理-创建业务介绍
Adobe Premiere foundation - time remapping (10)
程序员资源推荐指南
2. 银河麒麟离线模式下如何安装MySQL数据库
Cannot retrieve repository metadata 处理记录
These advantages of the Institute are really fragrant! The landing rate is still very high!