Python3+Selenium3自动化测试-(四)
selenium鼠标事件
# coding=utf-8 import time from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains driver = webdriver.Chrome() driver.get("https://www.baidu.com")
time.sleep(3) # 定位元素
ele_1 = driver.find_element(By.XPATH, '//*[@id="u1"]/a[9]')
ele_2 = driver.find_element(By.XPATH, '//*[@id="u1"]/a[8]') # 将鼠标悬停在元素1上3秒后再次悬停到元素2上
ActionChains(driver).move_to_element(ele_1).perform()
time.sleep(3)
ActionChains(driver).move_to_element(ele_2).perform()
time.sleep(3) driver.quit()
# coding=utf-8 import time from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains driver = webdriver.Chrome() driver.get("https://www.baidu.com")
time.sleep(3) # 定位元素
ele_1 = driver.find_element(By.XPATH, '//*[@id="u1"]/a[9]')
ele_2 = driver.find_element(By.XPATH, '//*[@id="u1"]/a[8]') # 将鼠标悬停在元素1上3秒后再次悬停到元素2上
ActionChains(driver).move_to_element(ele_1).perform()
time.sleep(3)
ActionChains(driver).move_to_element(ele_2).perform()
time.sleep(3) driver.quit()
"""
click(on_element=None) ——单击鼠标左键 click_and_hold(on_element=None) ——点击鼠标左键,不松开 context_click(on_element=None) ——点击鼠标右键 double_click(on_element=None) ——双击鼠标左键 drag_and_drop(source, target) ——拖拽到某个元素然后松开 drag_and_drop_by_offset(source, xoffset, yoffset) ——拖拽到某个坐标然后松开 key_down(value, element=None) ——按下某个键盘上的键 key_up(value, element=None) ——松开某个键 move_by_offset(xoffset, yoffset) ——鼠标从当前位置移动到某个坐标 move_to_element(to_element) ——鼠标移动到某个元素 move_to_element_with_offset(to_element, xoffset, yoffset) ——移动到距某个元素(左上角坐标)多少距离的位置 perform() ——执行链中的所有动作 release(on_element=None) ——在某个元素位置松开鼠标左键 send_keys(*keys_to_send) ——发送某个键到当前焦点的元素 send_keys_to_element(element, *keys_to_send) ——发送某个键到指定元素
"""
Python3+Selenium3自动化测试-(四)的更多相关文章
- Python3+Selenium3自动化测试-(二)
python3 元素定位和操作方法总结 # coding=utf-8 ''' #8种元素定位方法 find_element_by_id() find_element_by_name() find_el ...
- Python3+Selenium3自动化测试-(五)
这里来说一说selenium中的等待方式,其实在webdriver只有两种类型等待方式,显式等待和隐式等待,之前是在程序运行过程中使用time模块中的sleep进行代码的休眠进行强制等待,是显式等待中 ...
- Python3+Selenium3自动化测试-(三)
selenium键盘事件 #coding=utf-8 from selenium import webdriver import time from selenium.webdriver.common ...
- Python3+Selenium3自动化测试-(一)
完成环境的安装并测试之后,我们对Selenium有了一定的了解了,接下来我们继续驱动浏览器做一些基本操作: 窗口尺寸设置.网页截图.刷新.前进和后退 窗口尺寸设置 在测试过程中,我们可能会要求打开浏览 ...
- Selenium3自动化测试【27】Frame的操作
本篇文章内容摘要 " 讲解Python3+Selenium3如何处理Frame窗体" 同步视频知识与系列知识内容,可关注:[公众号]:柒哥测试:[WX]:Lee-890;[视频号] ...
- Selenium3自动化测试【28】单选框、复选框、下拉选择框
Html页面中的单选按钮.复选框.下拉框均可通过WebDriver实现操做.本节结合案例一起来看看WebDriver如何操做这些控件. 同步视频知识与系列知识内容,可关注:[公众号]:柒哥测试:[WX ...
- C#_自动化测试 (四) 自动卸载软件
在平常的测试工作中,经常要安装软件,卸载软件, 即繁琐又累. 安装和卸载完全可以做成自动化. 安装软件我们可以通过自动化框架,自动点击Next,来自动安装. 卸载软件我们可以通过msiexec命 ...
- Python3+unitest自动化测试初探(中篇)
目录 6.生成测试报告 7.编写邮件发送工具 8.发送邮件 发布 0 86 编辑 删除 Python3+unitest自动化测试初探(中篇)(2019-04-18 01:41) 发布 3 245 编辑 ...
- Python3+unitest自动化测试初探(下篇)
目录 9.用例结果校验 10.跳过用例 11.Test Discovery 12.加载用例 unittest官方文档 本篇随笔承接: Python3+unitest自动化测试初探(中篇) Python ...
随机推荐
- 5.14日学习内容1:jquery表单相关知识
<script> $comment.animate({height:'+=50'},400);//在原来的基础上加50: $('.smaller').click(function(){ i ...
- iOS开发中如遇到频繁的Http请求,取消之前已经发送的Http
主要精髓在于 第一点:不要initialize a new AFHTTPSessionManager object everytime 一定要把manager用成全局的 第二点:把请求返回的task对 ...
- 1 App Components - App组件
Android应用框架可以让你使用一系列可重用的组件来创建极其丰富和新颖的应用.本节说明了Android应用如何工作,如何使用组件来创建应用. Managing the Activity Lifecy ...
- c# 获取某日期所在周的第一天和最后一天(转)
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace WyfC ...
- The Ball Puzzle
自己做的小游戏 google play store: https://play.google.com/store/apps/details?id=com.ffipp.theBall app store ...
- centos7 mysql 5.7 官网下载tar安装
https://dev.mysql.com/downloads/mysql/5.7.html#downloads 下载好上传到服务器,解压后以此安装 libs,client,server三个rpm r ...
- easyui 扩展layout的方法,支持动态添加删除块
$.extend($.fn.layout.methods, { remove: function(jq, region){ return jq.each(function(){ var panel = ...
- Sql Server根据表名生成查询的存储过程(查询条件可选)
static void Main(string[] args) { string 表名 = "water_emstime"; string sql = "exec Get ...
- oracle11g卸载,10g之类版本通用
鉴于oracle一些比较稀奇的问题,本人没碰到的不能帮忙解决的.而且比较着急赶时间的亲们,我就只能推荐先卸载在安装的办法了,这个方法一般用时也就1个小时到1个半小时之间,切记按步骤删除,别漏删了,不然 ...
- 对Linux命令进一步学习vim(二)
今天,进一步学习Linux相关的命令,可能会有重复的地方,但学习本来就是不断重复的过程.故作小记! 1.安装了:vim ,,,一款Linux爱好者经常用到的ide sudo apt-get inst ...