app 自动化测试

 

 

# This sample code uses the Appium python client
# pip install Appium-Python-Client
# Then you can paste this into a file and simply run with Python

from appium import webdriver
import  time
caps = {}
caps["platformName"] = "Android"
caps["deviceName"] = "127.0.0.1:62001"
caps["appPackage"] = "com.kmxs.reader"
caps["appActivity"] = "com.kmxs.reader.home.ui.HomeActivity"

driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)

el1 = driver.find_element_by_id("com.kmxs.reader:id/iv_update_close")
el1.click()
time.sleep(3)
el2 = driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.View/androidx.viewpager.widget.ViewPager/android.widget.RelativeLayout/androidx.viewpager.widget.ViewPager/android.view.View/android.view.View/android.view.View[2]/android.widget.LinearLayout[2]/android.widget.TextView[1]")
el2.click()
time.sleep(2)
el3 = driver.find_element_by_id("com.kmxs.reader:id/book_detail_foot_free_read_tv")
el3.click()
time.sleep(10)
driver.tap([(864, 1342), (174, 1296)], 500)
driver.tap([(864, 1342), (174, 1296)], 500)*10

 这个是   锁屏自动化    

from appium import webdriver
# 导入WebDriverWait类
from appium.webdriver.common.touch_action import TouchAction
from selenium.webdriver.support.wait import WebDriverWait
import time
caps = {}
caps["platformName"] = "Android"
caps["deviceName"] = "127.0.0.1:62001"
caps["appPackage"] = "com.android.settings"
caps["appActivity"] = "com.android.settings.Settings"
driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
TouchAction(driver).press(x=420, y=175).move_to(x=272, y=1195).release().perform()
TouchAction(driver).press(x=200, y=1184).move_to(x=434, y=181).release().perform()
el1 = driver.find_element_by_xpath("//*[contains(@text,'安全')]").click()
#el2 = driver.find_element_by_xpath("//*[contains(@text,'屏幕锁定方式')]").click()
time.sleep(5)
el2 = driver.find_element_by_xpath('/hierarchy/android.widget.FrameLayout/android.view.View/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.ListView/android.widget.LinearLayout[1]/android.widget.RelativeLayout/android.widget.TextView[1]').click()
time.sleep(4)
TouchAction(driver).press(x=598,y=459).move_to(x=359,y=703).move_to(x=120,y=937).move_to(x=359,y=940).move_to(x=598,y=937).release().perform()

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值