添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
  • selenium URL重定向检查
  • Web自动化测试之playwright:Web元素操作
  • Web自动化测试之playwright:pages、popup、dialog和frame处理
  • Web自动化测试之playwright:执行JavaScript脚本
  • Web自动化测试之playwright:设置浏览器语言
  • APP自动化测试

  • Android ADB原理及常用命令
  • Android手机管理平台搭建:STF和atxserver2
  • Appium 介绍及环境安装
  • App控件定位:Android 控件介绍及元素定位方法
  • Appium元素定位(一)
  • Appium元素定位(二):uiautomator定位
  • Appium控件交互
  • Android WebView 测试
  • AppCrawler自动遍历测试
  • 自动遍历测试之Monkey工具
  • App自动化测试工具Uiautomator2
  • App自动化测试工具Airtest
  • Windows上实现iOS APP自动化测试:tidevice + WDA + facebook-wda / appium
  • Windows上实现iOS APP自动化测试:tidevice + WDA + airtest
  • 和facebook-wda库一起使用
  • iOS APP自动化:predicate定位
  • iOS APP自动化:class chain定位方法
  • 使用facebook-wda进行iOS APP自动化测试
  • 接口自动化测试

  • 接口测试简介及 Web 服务架构
  • Postman安装与使用
  • 接口测试框架Requests
  • cURL工具介绍及简单使用
  • charles SSL证书安装
  • 接口测试代理工具charles mock测试
  • mitmproxy 代理工具介绍:rewrite和map local实现
  • JMeter性能测试:JMeter安装及脚本录制回放
  • JMeter性能测试:JMeter多用户并发模拟及压测结果分析
  • JMeter性能监控系统:Jmeter + InfluxDB + Grafana
  • 系统性能监控:Prometheus + Grafana 监控服务器性能
  • Nmap扫描工具介绍
  • hydra暴力破解工具
  • Netdiscover网络扫描工具
  • Docker搭建持续集成平台Jenkins
  • 持续集成平台Jenkins配置方法介绍
  • 持续集成:jenkins + pytest + selenium + Git + Allure自动化测试
  • 持续集成:Jenkins插件Blue Ocean介绍
  • 持续集成:Jenkins API简单使用
  • 使用jenkins实现hexo博客自动发布
  • 使用GitHub Actions实现Hexo博客自动发布
  • Linux cron定时介绍
  • Jenkins集成Robot Framework
  • 持续集成:Jenkins中获取Robot Framework插件返回的Robot变量
  • 持续集成:Jenkins邮件通知配置方法介绍
  • 持续集成:Jenkins Pipeline共享库定义和使用
  • 持续集成:Jenkins Pipeline语法介绍
  • 持续集成:Jenkinsfile使用方法介绍
  • 持续集成:Jenkins API使用方法详细介绍
  • 持续集成:Jenkins pipeline全局变量
  • 测试管理平台

  • 禅道二次开发(一):开发环境配置
  • 禅道二次开发(二):禅道框架介绍
  • 禅道二次开发(三):二次开发实例
  • 禅道二次开发(四):集成
  • MySQL数据库安装配置详细教程
  • MySQL数据库基础入门
  • MySQL基础架构:SQL查询语句执行过程
  • MySQL日志系统:binlog、redo log和undo log
  • 计算机网络

  • TCP/IP协议架构介绍(一):网络接口层
  • TCP/IP协议架构介绍(二):网络层
  • TCP/IP协议架构介绍(三):传输层
  • TCP/IP协议架构介绍(四):应用层
  • Session、Cookie和Token介绍
  • 使用tshark命令解析tcpdump抓取的数据包
  • PHP笔记(一):开发环境配置
  • PHP笔记(二):字符串处理相关方法
  • PHP笔记(三):数组相关操作方法
  • PhpSpreadsheet读写Excel文件
  • markdown基本语法介绍
  • markdown图表语法Mermaid介绍
  • typora主题配置:公众号一键排版
  • 同一台电脑配置Gitee、Github 的 Git SSH公钥
  • Git简易教程-安装及简单使用
  • Linux安装和配置SVN服务器
  • Github shields徽章配置方法介绍
  • Hexo+Github/Gitee 搭建个人博客
  • Hexo个人博客主题配置
  • 电子书创建:Sphinx + Github + ReadTheDocs
  • Typora集成免费图床:PicGo + Gitee
  • Selenium ActionChains、TouchAction方法

    ActionChains和TouchAction可以用来模拟点击、双击、滑动等事件。ActionChains用于执行PC端的鼠标移动、按键、拖拽等事件;TouchActions用法与ActionChains类似,可以用来模拟PC和移动端的点击、滑动、拖拽等手势操作。

    ActionChains和TouchAction都是将动作存储在队列中,然后执行perform()方法,按队列顺序执行动作。

    ActionChains

    有两种执行方式

    ActionChains(driver).move_to_element(element).click(element).perform()
    
    actions=ActionChains(driver) 
    actions.move_to_element(element) 
    actions.click(element) 
    actions.perform()
    

    例一:点击,右键,双击操作

    测试页面:http://sahitest.com/demo/clicks.htm

    python代码:

    self.driver.get("http://sahitest.com/demo/clicks.htm") 
    click = self.driver.find_element_by_xpath("//*[@value='click me']") 
    doubleclick = self.driver.find_element_by_xpath("//*[@value='dbl click me']") 
    rightclick = self.driver.find_element_by_xpath("//*[@value='right click me']") 
    action= ActionChains(self.driver) 
    action.click(element_click) 
    action.context_click(element_rightclick) 
    action.double_click(element_doubleclick) 
    action. perform()
    

    python代码:

    self.driver.get("http://www.baidu.com") 
    ele = self.driver.find_element_by_link_text("新闻") 
    action = ActionChains(self.driver) 
    action.move_to_element(ele) 
    action.click() 
    action.perform()
    

    使用move_by_offset()方法实现点击页面,像素坐标可以使用截图工具来获取。

    python代码:

    ActionChains(self.driver).move_by_offset(x, y).click().perform() #左键点击
    ActionChains(self.driver).move_by_offset(x, y).context_click().perform() #右键点击
    

    例四:模拟键盘输入

    模拟键盘输入可以使用win32api模块,也可以用 selenium的WebElement对象的send_keys()方法来实现:

    element = self.driver.find_element_by_id(element) element.send_keys(**"test"**) element.send_keys(Keys.BACK_SPACE) assert element.get_attribute("value") == "tes"
    

    ActionChains类也可以模拟键盘输入:

    Action = ActionChains(driver) action.send_keys(Keys.BACK_SPACE) # 回退 
    action.key_down(Keys.CONTROL).send_keys('a').key_up(Keys.CONTROL) # CTRL+A 
    action.perform() # 执行
    

    测试页面:http://sahitest.com/demo/label.htm

    在文本框1中输入内容,然后将文本框1的内容复制粘贴到文本框2

    self.driver.get("http://sahitest.com/demo/label.htm") 
    ele1 = self.driver.find_element_by_xpath("/htmL/body/label[1]/input") 
    ele2 = self.driver.find_element_by_xpath("/html/body/label[2]/table/tbody/tr/td[2]/input") 
    ele1.click() 
    action= ActionChains(self.driver) 
    action.send_keys("testing").pause(1) 
    action.send_keys(Keys.SPACE).pause(1) # 空格 
    action.send_keys("1").pause(1) 
    action.send_keys(Keys.BACK_SPACE) #回退 
    action.key_down(Keys.CONTROL).send_keys('a').key_up(Keys.CONTROL) #CTRL+A 
    action.key_down(Keys.CONTROL).send_keys('c').key_up(Keys.CONTROL) #CTRL+C 
    action.key_down(Keys.CONTROL,ele2).send_keys('v').key_up(Keys.CONTROL) #CTRL+V 
    action.send_keys(Keys.BACK_SPACE).perform()
    python代码

    self.driver.get("http://sahitest.com/demo/dragDropMooTools.htm") 
    drag_ele = self.driver.find_element_by_id("dragger") 
    Item1 = self.driver.find_element_by_xpath("/htmL/body/div[2]") 
    Item2 = self.driver.find_element_by_xpath("/html/body/div[3]") 
    Item3 = self.driver.find_element_by_xpath("/html/body/div[4]") 
    action= ActionChains(self.driver) 
    action.drag_and_drop(drag_ele, Item1).pause(1) # 方法1 
    action.click_and_hold(drag_ele).release(Item2).pause(1)# 方法2 
    action.click_and_hold(drag_ele).move_to_element(Item3).release()# 方法3 
    action.perform()
    
  • scroll 点击并滚动

  • scroll_from_element 从某个元素位置开始手势点击并滚动(向下滑动为负数,向上滑动为正数)

  • flick_element——从某个元素位置开始手势滑动(负数:向上滑动,正数:向下滑动)

  • tap 在指定元素上点击

  • tap_and_hold 在指定元素上点击但不释放

  • 例一:点击、滑动

    百度搜索关键字,tap方法点击百度一下,滑动到底部,点击下一页

    python代码:

    self.driver.get("http://www.baidu.com") 
    input = self.driver.find_element_by_id("kw") 
    search = self.driver.find_element_by_id("su") 
    input.send_keys("test") 
    action = TouchActions(self.driver) 
    action.tap(search) 
    action.perform() 
    action.scroll_from_element(input, 0, 10000).perform() 
    next = self.driver.find_element_by_link_text("下一页 >") 
    next.click()