当前位置:网站首页>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 8-artificial neural network
- Elegant writing controller (parameter verification + unified exception handling)
- Adobe Premiere Basics - common video effects (cropping, black and white, clip speed, mirroring, lens halo) (XV)
- 什么是多范式编程语言,其中的“多范式”是什么意思?
- 6.29模拟赛总结
- js文本粒子动态背景
- 2022.6.29-----leetcode. five hundred and thirty-five
- 保持jupyter notebook在终端关闭时的连接方法
- 报错[warning] Neural network inference was performed on socket ‘RGB’, depth frame is aligned to socket
- Redis (I) -- getting started with redis (2) -- redis data type
猜你喜欢

Deep learning --- the weight of the three good students' scores (2)

Redis(一)--Redis入门(1)--Redis介绍、安装与启动、常用配置

Adobe Premiere foundation - material nesting (animation of Tiktok ending avatar) (IX)

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

idea怎么使用?

C Primer Plus 第12章_存储类别、链接和内存管理_代码和练习题

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

Amazing pandaverse:meta "borderless, to activate fashion attributes in the new journey of 2.0

如何将OAK相机当做网络摄像头使用?

The 8th "Internet +" competition - cloud native track invites you to challenge
随机推荐
MySQL 企业级开发规范
Hello, do you have any official website samples for MySQL CDC, PostgreSQL CDC? Give me a link to learn
js将秒转换成“2h30min50s”的格式
These advantages of the Institute are really fragrant! The landing rate is still very high!
Data-* attribute usage
Fastdfs
踩坑记:JSON.parse和JSON.stringify
jdbc_相關代碼
2022.6.29-----leetcode. five hundred and thirty-five
C Primer Plus Chapter 12_ Storage categories, links, and memory management_ Codes and exercises
PostGIS generate graphic cut
Programmer Resource Recommendation Guide
【网络是怎么连接的】第三章 探索集线器,交换机和路由器
Adobe Premiere foundation - cool text flash (14)
CentOS 7.5 install MySQL 8.0.27---yum
Up to 81.98%! Announcement of undergraduate study rate of more than 100 "double first-class" Universities
Leetcode 984. String without AAA or BBB (thought of netizens)
Sd6.24 summary of intensive training
源码安装MAVROS
Amazing pandaverse:meta "borderless, to activate fashion attributes in the new journey of 2.0