App自动化之Tap Bounds值定位-----初级篇(6)

一、先获取Bounds值

在这里插入图片描述

二、代码实现

from appium import webdriver
from appium.webdriver.common.touch_action import TouchAction
import time

dic = {
    "platformVersion":"5.1.1",
    "platformName":"Android",
    "deviceName":"127.0.0.1:62001",
    "appPackage":"com.jhss.youguu",
    "appActivity":".SplashActivity"
}

driver = webdriver.Remote("http://localhost:4723/wd/hub",dic)
driver.implicitly_wait(20)
time.sleep(5)
TouchAction(driver).press(x = 837,y=760).move_to(x=56,y=868).release().perform()
time.sleep(5)
TouchAction(driver).press(x = 837,y=760).move_to(x=56,y=868).release().perform()
time.sleep(5)
TouchAction(driver).press(x = 837,y=760).move_to(x=56,y=868).release().perform()
time.sleep(5)
TouchAction(driver).tap(x=462,y=1457).perform()

# 通过bounds值关闭广告
time.sleep(3)  #等待广告弹出
driver.tap([(656,563),(712,619)])

bounds是app自动化特有的api,因为他是点击的一块区域,在使用时要考虑到会不会点到别的地方?

在进行输入内容后的一些下拉内容选择时,bounds还是不错的选择


版权声明:本文为weixin_46457203原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。