码迷,mamicode.com
首页 > 其他好文 > 详细

yonghui apk安装卸载 滑动,截图

时间:2019-02-12 18:36:35      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:system   log   install   \n   for   apk安装   rmi   launch   __name__   

# coding=utf-8
from appium import webdriver
import time
from time import sleep
import os
os.system("adb install yonghui438.apk")

desired_caps = {
‘platformName‘: ‘Android‘,
‘deviceName‘: ‘cf0d6915‘,
‘platformVersion‘:‘6.0‘,
‘noReset‘:True,
‘noSign‘:True,
‘appPackage‘:‘cn.yonghui.hyd‘,
‘appActivity‘:‘cn.yonghui.hyd.LaunchActivity‘,
# ‘unicodeKeyboard‘: True,
# ‘resetKeyboard‘: True,
}
launchApp = webdriver.Remote(‘http://127.0.0.1:4723/wd/hub‘, desired_caps)

#启动页的4个允许按钮点击
time.sleep(5)
launchApp.find_element_by_id(‘com.lbe.security.miui:id/permission_allow_button‘).click()
launchApp.find_element_by_id(‘com.lbe.security.miui:id/permission_allow_button‘).click()
launchApp.find_element_by_id(‘com.lbe.security.miui:id/permission_allow_button‘).click()
launchApp.find_element_by_id(‘com.lbe.security.miui:id/permission_allow_button‘).click()
def swipLeft(launchApp,t=500,n=1):
S = launchApp.get_window_size()
x1=S[‘width‘]*0.75
y1=S[‘height‘]*0.5
x2=S[‘width‘]*0.25
y2=S[‘height‘]*0.5
for i in range(n):
launchApp.swipe(x1,y1,x2,y2,t)
if __name__ =="__main__":
print (launchApp.get_window_size())
sleep(2)
swipLeft(launchApp,n=1)
time.sleep(5)
launchApp.find_element_by_class_name(‘android.widget.ImageView‘).click()
time.sleep(3)
#点击首页
#launchApp.find_element_by_xpath(‘(//android.widget.ImageView[@content-desc="icon"])[1]‘).click()
time.sleep(5)
#点击新人礼的弹窗
launchApp.find_element_by_xpath(‘/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.RelativeLayout/android.view.ViewGroup/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.view.ViewGroup/android.support.v4.view.ViewPager/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.view.ViewGroup/android.support.v7.widget.RecyclerView/android.widget.RelativeLayout/android.widget.RelativeLayout/android.support.v4.view.ViewPager/android.widget.ImageView‘).click()
time.sleep(2)
#登录手机号,每次要改
launchApp.find_element_by_id(‘cn.yonghui.hyd:id/sfLoginPhoneInputEt‘).send_keys(‘13997894076‘)
time.sleep(3)
launchApp.find_element_by_id(‘cn.yonghui.hyd:id/sfLoginPhoneInputConfirmBtn‘).click()
time.sleep(3)
launchApp.find_element_by_id(‘cn.yonghui.hyd:id/sfLoginAuthInputEt‘).send_keys(‘601933‘)
time.sleep(5)
launchApp.get_screenshot_as_file(‘E:\yoyo_jiekou\screenshots\\newmembercoupon.png‘)
launchApp.find_element_by_id(‘cn.yonghui.hyd:id/close_img‘).click()
launchApp.remove_app(‘cn.yonghui.hyd‘)
#确认是否卸载了,false就是卸载了
a = launchApp.is_app_installed(‘cn.yonghui.hyd‘)
print (a)









yonghui apk安装卸载 滑动,截图

标签:system   log   install   \n   for   apk安装   rmi   launch   __name__   

原文地址:https://www.cnblogs.com/zhuxiaoqingxixi/p/10366627.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!