python selenium常用基本方法---H5和键盘鼠标操作
一、模拟手机打开页面(H5测试)
from selenium import webdriver
mobile_emulation = {'deviceName':'iPhone X'}
options = webdriver.ChromeOptions()
options.add_experimental_option('mobileEmulation',mobile_emulation)
driver = webdriver.Chrome(chrome_options=options)
driver.maximize_window()
driver.get("http://www.baidu.com")
二、鼠标、键盘操作(只解释拖拽和Enter,其他需要自己补充)
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium import webdriver
driver = webdriver.Chrome ActionChains(driver).drag_and_drop(element1,element2).perform() #拖拽
driver.find_element_by_xpath(element).send_keys(Keys.ENTER) #Enter
三、starts-with、contains定位
<div style="border:solid 10px #FFD324;width:100px;height:100px;">start-with</div>
//div[starts-with(@style,'border')] <div class="dcbe07da-9af1-44ae-bab0-1d2ea88dd775-success" style="width:70px;height:50px;border:solid 10px #8a1f11;align-content:center">contains</div>
//div[contains(@class,'success')]
//*[contains(text(),'contains')]
python selenium常用基本方法---H5和键盘鼠标操作的更多相关文章
- 屏幕实时显示键盘鼠标操作软件keycastow,适合做视频教程
屏幕实时显示键盘鼠标操作软件keycastow,适合做视频教程 学习了:https://www.52pojie.cn/thread-535154-1-1.html 进行键盘按键的屏幕实时显示:
- python字符串常用的方法解析
这是本人在学习python过程中总结的一些关于字符串的常用的方法. 文中引用了python3.5版本内置的帮助文档,大致进行翻译,并添加了几个小实验. isalnum S.isalnum() -> ...
- Python selenium常用用法
1.获取当前页面的Url 方法:current_url 实例:driver.current_url 2.获取元素坐标 方法:location 解释:首先查找到你要获取元素的,然后调用location方 ...
- Selenium键盘鼠标操作总结
鼠标操作 org.openqa.selenium.interactions.Actions 1.给元素设置焦点. 有时对于a标签等,为了不跳转到别的链接,但是需要设置焦点时就可使用. action.m ...
- python selenium八大定位方法
一.定位方法 注意:元素属性必须唯一存在 #id定位 find_element_by_id() #name定位 find_element_by_name() #class_name定位 find_el ...
- python selenium(定位方法)
一.定位方法 注意:元素属性必须唯一存在 #id定位 find_element_by_id() #name定位 find_element_by_name() #class_name定位 find_el ...
- Python&Selenium智能等待方法封装
摘要:本篇博文用几行代码展示Python和Selenium做自动化测试时常见的显示等待和封装 # 用于实现智能等待页面元素的出现 # encoding = utf-8 ""&quo ...
- 解析python部分常用魔术方法
def __add__(self, *args, **kwargs): # real signature unknown """ Return self+value. & ...
- python的常用魔法方法详细总结
构造和初始化 __init__我们很熟悉了,它在对象初始化的时候调用,我们一般将它理解为"构造函数". 实际上, 当我们调用x = SomeClass()的时候调用,__init_ ...
随机推荐
- PAT 1059 Prime Factors[难]
1059 Prime Factors (25 分) Given any positive integer N, you are supposed to find all of its prime fa ...
- Mvc ModelState.isValid为false时,检查时那个字段不符合规则的代码
List<string> sb = new List<string>(); //获取所有错误的Key List<string> Keys = ModelState. ...
- JMS API(二)
JMS 公共API 接口共7个: 1.ConnectionFactory 2.Destination 3.Connection 4.Session 5.Message 6.MessageProduce ...
- Could not connect to '192.168.89.144' (port 22)
xshell连接linux主机时,会出现错误:Could not connect to '192.168.89.144' (port 22): Connection failed. 但是这时能ping ...
- Ubuntu16.04安装印象笔记
Nixnote 是一个 Evernote 开源客户端,原名 Nevernote.Evernote 是一个著名的笔记等个人资料整理和同步软件, 因为 Evernote 没有 Linux 下的官方版本,因 ...
- 对Spring Ioc 以及DI的精彩理解
转:http://blog.csdn.net/cyjs1988/article/details/50352916 学习过spring框架的人一定都会听过Spring的IoC(控制反转) .DI(依赖注 ...
- Koa源码解析
Koa是一款设计优雅的轻量级Node.js框架,它主要提供了一套巧妙的中间件机制与简练的API封装,因此源码阅读起来也十分轻松,不论你从事前端或是后端研发,相信都会有所收获. 目录结构 首先将源码下载 ...
- 前端js实现字符串/图片/excel文件下载
在web开发中,如果你想让用户下载或者导出一个文件,应该怎么做呢?传统的做法是在后端存储或者即时生成一个文件来提供下载功能,这样的优势是可以做权限控制.数据二次处理,但缺点是需要额外发起请求.增大服务 ...
- mysql命令行创建数据库
create database publiccms; grant all privileges on publiccms.* to root@localhost identified by 'publ ...
- .net 数据缓存(二)之Redis部署
现在的业务系统越来复杂,大型门户网站内容越来越多,数据库的数据量也越来愈大,所以有了“大数据”这一概念的出现.但是我们都知道当数据库的数据量和访问过于频繁都会影响系统整体性能体验,特别是并发量高的系统 ...