您现在的位置是:主页 > news > 秦皇岛营销式网站制作/网络竞价推广开户
秦皇岛营销式网站制作/网络竞价推广开户
admin2025/5/3 19:18:34【news】
简介秦皇岛营销式网站制作,网络竞价推广开户,网站月流量什么意思,淘宝上的网站建设靠谱吗今天讲一下appium的启动,和一些简单的操作【appium安装文档找小编要教程吧】首先连接手机设备。先看下怎么电脑怎么连接手机设备的吧。adb连接手机的两种方式,【可能需要你们学一下adb命令,跟dos命令也差不多】一:1. 在手机上启用…
秦皇岛营销式网站制作,网络竞价推广开户,网站月流量什么意思,淘宝上的网站建设靠谱吗今天讲一下appium的启动,和一些简单的操作【appium安装文档找小编要教程吧】首先连接手机设备。先看下怎么电脑怎么连接手机设备的吧。adb连接手机的两种方式,【可能需要你们学一下adb命令,跟dos命令也差不多】一:1. 在手机上启用…
今天讲一下appium的启动,和一些简单的操作【appium安装文档找小编要教程吧】
首先连接手机设备。先看下怎么电脑怎么连接手机设备的吧。
adb连接手机的两种方式,【可能需要你们学一下adb命令,跟dos命令也差不多】
一:
1. 在手机上启用USB调试
2. CMD窗口输入adb devices,此时可以看到自己的设备。
二:
命令行输入:如 adb connect 127.0.0.1:62001
输入:adb devices 查询连接的设备。出现下图就算连接成功了
下面开始写代码吧。
#-*-coding:utf-8 -*-import osimport time import unittestfrom selenium import webdriver#coding =utf-8#初始化from selenium import webdriverfrom appium import webdriverimport osimport timedef setUp(self): PATH = lambda p: os.path.abspath(os.path.join(os.path.dirname(__file__), p)) desired_caps = {} desired_caps['platformName'] = 'Android' # 设备系统 desired_caps['platformVersion'] = '9.0' # 设备系统版本 desired_caps['deviceName'] = '127.0.0.1:62001' # 设备名称 # 7C5A10B34543 # desired_caps['app'] = PATH(r"C:\\103.0.9-20171213-001.apk") desired_caps['app']=PATH(r"D:\Test\hupu_7.3.13_7403_11031test_hupuupdate.apk") desired_caps['appPackage'] = 'com.hupu.games' desired_caps['appActivity'] = 'com.hupu.games.activity.LaunchActivity' desired_caps['unicodeKeyboard'] = True desired_caps['resetKeyboard'] = True self.driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps) time.sleep(20)
一些基本操作的封装
# coding=utf-8from appium import webdriverimport timefrom appium.webdriver.common.touch_action import TouchActioncapbilities={ "platformName": "Android", "deviceName": 'CLB0218621004765', "appPackage": "com.hupu.games", "appActivity": "com.hupu.games.activity.LaunchActivity", "app":'D:\\Test\\WL-APP-Games_Android-channels-release6300814596592599011.apk', }class getswipe(object): def __init__(self): self.driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", capbilities) self.size = self.driver.get_window_size()#获取屏幕的大小,返回的形式是{'width': 1080, 'height': 1812} self.width = self.size["width"]#获取宽 self.height = self.size["height"]#获取高 def clickscreen(self): x1 = self.width /10* 5 x1=int(x1) y1 = self.height / 10 * 5 y1=int(y1) self.driver.tap([(x1,y1),(x1,y1)]) self.driver.find_element_by_id("com.hupu.games:id/btn_back").click() def swipeUp(self): x1 = self.width / 2 y1 = self.height / 10 * 7#获取高的十分之九的位置 x2 = x1 y2 = self.height / 10 * 5#获取十分之一的位置 time.sleep(2) self.driver.swipe(x1,y1,x2,y2,100)#向上滑动x坐标不变,y坐标变小 def swipeDown(self): x1 = self.width / 2 y1 = self.height / 10 * 1 x2 = x1 y2 = self.height / 10 * 9 self.driver.swipe(x1, y1, x2, y2)
操作页面逻辑可以另外建个类,单独写
def mobilelogin(self): # 切换到更多页面 self.driver.find_element_by_id("com.hupu.games:id/btn_mytab").click() time.sleep(2) # 点击使用手机登陆 self.driver.find_element_by_id("com.hupu.games:id/mobile_login_new").click() time.sleep(2) # 选择账号密码登陆 self.driver.find_element_by_id("com.hupu.games:id/bt_accout_login").click() time.sleep(1) # 点击账户输入框 # self.driver.find_element_by_id("com.hupu.games:id/username_text").click() self.driver.find_element_by_id("com.hupu.games:id/username_text").send_keys("test180") # self.driver.find_element_by_id("com.hupu.games:id/password_text").click() self.driver.find_element_by_id("com.hupu.games:id/password_text").send_keys("123456") self.driver.find_element_by_id("com.hupu.games:id/btn_account_submit") def wx_login(self): self.driver.find_element_by_id("com.hupu.games:id/weixin_login_new").click() # def BBS(self): # self.driver.find_element_by_id("com.hupu.games:id/btn_bbs").click() def swipeAction(self,direction):#定义一个滑动函数,传入一个方向即可 if direction == "up": self.swipeUp() elif direction == "down": self.swipeDown() elif direction == "left": self.swipeLeft() else: self.swipeRight()if __name__ == "__main__": vivoSwipe = getswipe() vivoSwipe.swipeAction("up")#告知滑动的方向即可
执行脚本:
import timefrom login import getswipeif __name__ == "__main__": vivoSwipe = getswipe() time.sleep(15) # vivoSwipe.BBS() while True: vivoSwipe.clickscreen() vivoSwipe.swipeUp()
以前没怎么写过公众号,没啥经验。有看不懂的地方欢迎进群一起交流探讨。
本公众号不定时发布互联网岗位内推招聘信息,欢迎关注 “橙子软件测试”,跳槽涨薪