当前位置:网站首页>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 类提供了以下方法来操控浏览器的后退、前进和刷新等操作。

边栏推荐
- Machine learning 7-Support vector machine
- 踩坑记:JSON.parse和JSON.stringify
- Amazing pandaverse:meta "borderless, to activate fashion attributes in the new journey of 2.0
- 2. 在STM32CubeMX建立的Keil5工程中添加自定义的相关文件
- 数据分析基础--预测模型
- Adobe Premiere foundation - sound adjustment (volume correction, noise reduction, telephone tone, pitch shifter, parameter equalizer) (XVIII)
- 保持jupyter notebook在终端关闭时的连接方法
- JS converts seconds to "2h30min50s" format
- What is a multi paradigm programming language and what does "multi paradigm" mean?
- Adobe Premiere foundation - cool text flash (14)
猜你喜欢

Shandong University project training (VIII) design rotation map entry page

Cannot retrieve repository metadata 处理记录

Adobe Premiere Basics - general operations for editing material files (offline files, replacing materials, material labels and grouping, material enabling, convenient adjustment of opacity, project pa

Error building sqlsession problem

How to use the low code platform of the Internet of things for service management?

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

js文本粒子动态背景

Adobe Premiere foundation - cool text flash (14)

About microservices

Sword finger offer 34 Path DFS method for binary tree neutralization
随机推荐
2. 银河麒麟离线模式下如何安装MySQL数据库
1. use stm32cubemx to establish stm32g030c8t6 project
Sd6.22 summary of intensive training
CentOS 7.5 install MySQL 8.0.27---yum
Goldfish rhca memoirs: do447 build advanced job workflow -- create workflow job template and start workflow job
Error building sqlsession problem
markdown常用字体
SD6.25集训总结
6.29 simulation summary
Machine learning 7-Support vector machine
Notes on spintronics - zhangshufeng
The table ‘table_name‘ is full 异常排查及解决方案
mysql -connector/j驱动下载
svg画圆路径动画
The 8th "Internet +" competition - cloud native track invites you to challenge
Up to 81.98%! Announcement of undergraduate study rate of more than 100 "double first-class" Universities
Encryption and decryption of 535 tinyurl
Know that Chuangyu has helped the energy industry in asset management and was selected into the 2021 IOT demonstration project of the Ministry of industry and information technology
Mac: MySQL 66 questions, 20000 words + 50 pictures!
Adobe Premiere基础-素材嵌套(制作抖音结尾头像动画)(九)