selenium之动作链
概念:一组连续的行为动作
爬取网站:https://www.runoob.com/try/try.php?filename=jqueryui-api-droppable
背景:把左边的方块横竖往下便宜17px
from selenium import webdriver
from time import sleep
from selenium.webdriver import ActionChains #动作链
#实例化一个浏览器对象
bro = webdriver.Chrome(executable_path='./chromedriver.exe') bro.get('https://www.runoob.com/try/try.php?filename=jqueryui-api-droppable') sleep(2) #如果定位的标签是存在于iframe标签之中,在定位前必须先执行以下操作
bro.switch_to.frame('iframeResult') div_tag = bro.find_element_by_xpath('//*[@id="draggable"]') print(div_tag)
#实例化一个动作链对象,且将该对象链应用到当前的页面中
action = ActionChains(bro) action.click_and_hold(div_tag) for i in range(1,6):
#action.move_by_offset(17,17).perform() #表示立即执行动作链
action.move_by_offset(17,17).perform()
sleep(0.5) sleep(2)
bro.quit()
selenium之动作链的更多相关文章
- selenium中动作链的使用
一.问题 我们有时候在使用selenium的时候,会遇到悬停后点击元素的操作,因此需要一个动作链来完成这个功能. 二.解决 从selenium的包中导入actionchains函数,利用xpath找到 ...
- Selenium之动作链(ActionChains)
用selenium做自动化,有时候会遇到需要模拟鼠标操作才能进行的情况,比如单击.双击.点击鼠标右键.拖拽等等.而selenium给我们提供了一个类来处理这类事件——ActionChains se ...
- selenium的动作链 actionchains
click(on_element=None) ——单击鼠标左键 click_and_hold(on_element=None) ——点击鼠标左键,不松开 context_click(on_elemen ...
- Selenium 动作链
Selenium 模拟浏览器操作,有一些操作,它们没有特定的执行对象,比如鼠标拖曳.键盘按键等,这些动作用另一种方式来执行,那就是动作链 更多动作链参考官网:https://selenium-pyth ...
- selenium动作链
简介 一般来说我们与页面的交互可以使用Webelement的方法来进行点击等操作. 但是,有时候我们需要一些更复杂的动作,类似于拖动,双击,长按等等. 这时候就需要用到我们的Action Chains ...
- selenium处理iframe和动作链
selenium处理iframe和动作链 iframe iframe就是一个界面里嵌套了其他界面,这个时候selenium是不能从主界面找到子界面的属性,需要先找到子界面,再去找子界面的属性 动作链( ...
- 爬虫04 /asyncio、selenium规避检测、动作链、无头浏览器
爬虫04 /asyncio.selenium规避检测.动作链.无头浏览器 目录 爬虫04 /asyncio.selenium规避检测.动作链.无头浏览器 1. 协程asyncio 2. aiohttp ...
- 爬虫selenium中动作链接ActionChains
一.基本语法 生成一个动作actions=ActionChains(driver) 动作添加方法actions.方法 执行 actions.perform() 二.方法列表 click(on_elem ...
- python爬虫从入门到放弃(八)之 Selenium库的使用
一.什么是Selenium selenium 是一套完整的web应用程序测试系统,包含了测试的录制(selenium IDE),编写及运行(Selenium Remote Control)和测试的并行 ...
随机推荐
- js和微信小程序本地获取东八北京时间
changeCount(){ // 目标时区,东8区 const targetTimezone = -8; // 当前时区与中时区时差,以min为维度 const dif = new Date().g ...
- Objective-C如何自己实现一个基于数组下标的属性访问模式
在iOS6.0以及OS X10.8之后,Apple引入了一套非正式协议(informal protocol)与Objective-C语法直接绑定.当你实现了这其中的方法之后即可使用数组下标来访问属性元 ...
- android设置gps自动开启
1.第一种方法 private void toggleGPS() { Intent gpsIntent = new Intent(); gpsIntent.setClassName("com ...
- SqlServer2008数据库的备份与还原
1.先是备份数据 1.1.登录sql server management studio 1.2.选中需要备份数据库,右击鼠标,如下图: 1.3.点击备份之后,如下图; 2.数据还原准备 ps: 在开始 ...
- C++ STL 逆转旋转 reverse reverse_copy rotate
#include <iostream>#include <algorithm>#include <vector>#include <iterator> ...
- Build Telemetry for Distributed Services之Elastic APM
官网地址:https://www.elastic.co/guide/en/apm/get-started/current/index.html Overview Elastic APM is an a ...
- kubernets部署sock-shop微服务电商平台(11)
一.准备条件 确保kubernetes可以访问:reg.yunwei.edu镜像库(vim /etc/hosts) 需要准备镜像: [root@cicd sock-shop]# cat com ...
- LeetCode刷题1——只出现一次的数字
一.题目要求 二.题目背景 位运算:或,异或,与,移位 三.解题思路 (1)要求算法时间复杂度是线性的,O(n),想到的是先将列表排序,排序后相同的数值两两之间前后相邻,进行偶数次循环,判断两两数值是 ...
- manjaro Docker环境配置记
1.系统配置如下: ‘by: /home/inkhin/桌面/深度截图_选择区域_20191004145104.png [吐槽: ChromeLinux版居然不能用博客园TinyMce的上传图片功能] ...
- vue-cli 打包后提交到线上出现 "Uncaught SyntaxError:Unexpected token <" 报错
参考链接:https://segmentfault.com/a/1190000016919340