selenium 经常用到的API
一、webdriver 属性及方法:
1、获取当前页面的 url
driver.current_url
2 、获取窗口相关信息
get_window_position() 返回窗口x,y坐标
get_window_size() 返回窗口长宽尺寸
get_window_rect() 返回窗口x,y坐标及长宽尺寸
title
3 、截屏
driver.save_screenshot('path/xx.png')
diriver.get_screenshot_as_file(filename)
4 、定位元素
from selenium.webdriver.common.by import By
find_element(by,target)
find_element_by_*(target)
5、执行脚本
execute_script(script,*args)
6、关闭浏览器
close()
7、关闭浏览器并退出驱动程序
quit()
8、cookie操作
brower.delete_all_cookies()删除所有的cookies
brower.delete_cookie(name)删除name键值对
brower.get_cookies()返回所有的cookies(是一个字典列表)
brower.get_cookie(name)根据name返回对应的value
9、返回上一页
back()
10、返回窗口长宽
get_window_size()
11、
二、WebElement 属性及方法:
1、获取节点属性
get_attribute(name)
get_property(name)
2 、清空输入框与向输入框添加值,并提交表单或点击
clear() 清空输入框
send_keys(value) 向输入框添加值
submit() 提交表单(一般用于submit节点)
click() 点击一下(一般用于button或链接)
3、获取 css 属性值
value_of_css_property(property_name)
4、元素几个属性判断
is_enabled() 判断元素是否可用
is_selected()判断元素是否选中
is_displayed()判断元素是否显示出来了
三、ActionChains类引发的鼠标操作
导入ActionChains模块:from selenium.webdriver.common.action_chains import ActionChains
1、鼠标右键点击
ActionChains(driver).context_click(driver.find_element_by_id('id')).perform()
2、
3、
4、
5、
selenium 经常用到的API的更多相关文章
- <译>Selenium Python Bindings 6 - WebDriver API
本章涉及Selenium WebDriver的所有接口. Recommended Import Style 推荐的导入风格如下: from selenium import webdriver 然后,你 ...
- Selenium with Python 009 - WebDriver API
官方API文档:https://seleniumhq.github.io/selenium/docs/api/py/api.html 更多详情,最好的学习方式可以查阅官方API文档或直接阅读源码,本文 ...
- Selenium WebDriver(Python)API
1.通过示例介绍Selenium-WebDriver 一个简单的入门方法就是这个例子,它在Google上搜索术语“Cheese”,然后将结果页面的标题输出到控制台. java csharp pytho ...
- [译]Selenium Python文档:七、WebDriver API接口
由于API文档格式不太适合cnblog博客,暂且翻译一部分,且暂未校对 注意:这不是官方文档,官方 API文档在这里. 本章包含Selenium WebDriver的所有接口 推荐import风格 本 ...
- 摘:Selenium api学习
selenium: selenium2(WebDriver) API1.1 下载selenium2.0的包 官方download包地址:http://code.google.com/p/seleniu ...
- Python + Selenium 实现登录Office 365
最近捡起之前用的Python + Selenium实现工作中需要的登录Office 365功能.(吐槽:国内网络真是卡,登录Office 365实属不易.另外Selenium这样的网站都要墙,无法理解 ...
- selenium2.0(WebDriver) API
1.1 下载selenium2.0的包 官方download包地址:http://code.google.com/p/selenium/downloads/list 官方User Guide: h ...
- 使用python selenium webdriver模拟浏览器
selenium是进行web自动化测试的一个工具,支持C,C++,Python,Java等语言,他能够实现模拟手工操作浏览器,进行自动化,通过webdriver驱动浏览器操作,我使用的是chrome浏 ...
- 在selenium2.0中使用selenium1.0的API
Selenium2.0中使用WeDriver API对页面进行操作,它最大的优点是不需要安装一个selenium server就可以运行,但是对页面进行操作不如selenium1.0的Selenium ...
随机推荐
- jquery:after append appendTo三个函数的区别
1.查找元素节点 var $li = $(“ul li:eq(0)”);//获取ul标记下的第一个li,也可以写成 $(“#ulID li:eq(0)”); 2.查找元素属性 利用jq ...
- Apache2.4 新virtualhost
创建配置文件 /etc/apache2/sites-available# sudo nano mysite.conf <VirtualHost *:> #ServerName hello. ...
- HDU 4930 Fighting the Landlords(扯淡模拟题)
Fighting the Landlords 大意: 斗地主... . 分别给出两把手牌,肯定都合法.每张牌大小顺序是Y (i.e. colored Joker) > X (i.e. Black ...
- (LeetCode)两个链表的第一个公共节点
LeetCode上面的题目例如以下: Write a program to find the node at which the intersection of two singly linked l ...
- 在4x4的棋盘上摆满了黑白棋子,黑白两色的位置和数目随机其中左上角坐标为(1,1),右下角坐标为(4,4),现在依次有一些翻转操作,要对一些给定支点坐标为中心的上下左右四个棋子的颜色进行翻转,请计算出翻转后的棋盘颜色。
// ConsoleApplication10.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream& ...
- js 第一篇(常用交互方法)
1. cocument.write("content") //向html 直接写入内容 2. alert("content") // 警告对话框 3. conf ...
- 多媒体开发之---h264中 的RTP PAYLOAD 格式
H.264 视频 RTP 负载格式 1. 网络抽象层单元类型 (NALU) NALU 头由一个字节组成, 它的语法如下: +---------------+ |0|1|2|3|4|5|6|7 ...
- 使用Reveal来查看别人的APP界面+白苹果不刷机解决方式
Reveal这个强大的界面调试工具.能够实时查看.改动view的属性,大体上实现了iOS程序猿梦寐以求的功能.比方,有时候我们加入了一个view,可是那个view死活不显示出来,这时候祭出Reveal ...
- c# 根据枚举Value 获得名称
// 定义枚举类型enum sotype : int { book=1, pen=2, other=3 } // 输出名称 switch (Enum.GetName(typeof(sotype), 1 ...
- tomcat端口问题
https://segmentfault.com/q/1010000008858162?_ea=1777730