当前位置: 首页 > news >正文

响应式企业网站开发所用的平台西安知名网站推广

响应式企业网站开发所用的平台,西安知名网站推广,汕头建站模板厂家,网站怎么做描文本1、查看环境初始化参数 确保appium已经开起来了#xff0c;设置ip ,并点击启动 打开夜神模拟器#xff0c;点击工具--设置 最下面的版本说明#xff0c;双击进去 版本号这里再去单击。 直到进入到开发者模式。 可能我们不是开发者模式打开的状态#xff0c;所以软件访问模…1、查看环境初始化参数 确保appium已经开起来了设置ip ,并点击启动 打开夜神模拟器点击工具--设置 最下面的版本说明双击进去 版本号这里再去单击。 直到进入到开发者模式。 可能我们不是开发者模式打开的状态所以软件访问模拟器时它有可能不让我们连。 要重启一下模拟器 重启模拟器之后开发者模式才能生效。 此时再用命令行查看可以看到设备号。 caps{platformName:Android, #设置platformName:手机系统名称AndroidplatformVersion:7.1.2, # #设置platformVersion:手机系统版本deviceName:127.0.0.1:52001 , #设置deviceName:设备名称appPackage:uni.UNI765428A, #设置appPackage:被测程序包名appActivity:io.dcloud.PandoraEntry #设置appActivity:被测程序活动名 } 手机端参数查看命令有那些。每个人设备及端口号不一样所以需要单独看。 adb  devices 查看包名 adb shell dumpsys activity activities |findstr mFocusedActivity 打开appium Inspector 开始定位元素。 比如这个id,先点1混合定位模式再点2开始定位点3要定位的元素最后拷贝它的id或者xpath 定位命令和web没什么不同 driver.find_element(By.ID,com.android.packageinstaller:id/permission_allow_button).click() 2、test_loginV1.py  跑通流程 先导入必备的包及写上版本说明 #***************************************** #v1.0:app独立自动化测试 脚本--初始化登录 #***************************************** #导入类库 import timefrom appium.webdriver.webdriver import WebDriver from appium.webdriver.webdriver import By #手机参数初始化 #查询程序包名的命令:adb shell dumpsys activity activities| findstr mFocusedActivity#设置appPackage:被测程序包名定义程序包名的参数 caps{platformName:Android, #设置platformName:手机系统名称AndroidplatformVersion:7.1.2, # #设置platformVersion:手机系统版本deviceName:127.0.0.1:52001 , #设置deviceName:设备名称appPackage:uni.UNI765428A, #设置appPackage:被测程序包名appActivity:io.dcloud.PandoraEntry #设置appActivity:被测程序活动名 }#启动appium driverWebDriver(http://127.0.0.1:4723/wd/hub,caps) 点击允许按钮 #进行元素定位 #点击允许按钮 time.sleep(3) driver.find_element(By.ID,com.android.packageinstaller:id/permission_allow_button).click() #允许电话管理 time.sleep(2) driver.find_element(By.ID,com.android.packageinstaller:id/permission_allow_button).click()#输入后台服务器地址 time.sleep(5) xpath_service/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[1]/android.view.View/android.widget.EditText servicepathhttps://lefeiwisdom-3pt-2t6a7-www.vip.51env.net driver.find_element(By.XPATH,xpath_service).clear() time.sleep(1) driver.find_element(By.XPATH,xpath_service).send_keys(servicepath) #点击确定按钮 time.sleep(3) xpath_ok/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[2] driver.find_element(By.XPATH,xpath_ok).click() #点击验证码登录按钮 xpath_check/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[4] driver.find_element(By.XPATH,xpath_check).click() time.sleep(2) #输入手机号码 xpath_phone/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[5]/android.view.View/android.widget.EditText # id_phonec52abd0b-3c7b-4b6f-a2a0-f386d56bebd8 driver.find_element(By.XPATH,xpath_phone).send_keys(13800138001) time.sleep(2) #输入验证码 xpath_checkcode/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[6]/android.view.View/android.widget.EditText driver.find_element(By.XPATH,xpath_checkcode).send_keys(111111) #接受协议 xpath_allow/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[9] time.sleep(2) driver.find_element(By.XPATH,xpath_allow).click() #登录按钮 time.sleep(2) xpath_login/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[8] driver.find_element(By.XPATH,xpath_login).click() 完成登录 3、test_loginV2.py 面向过程的封装 #方法0手机驱动参数输出化设置 #方法1两个允许按钮服务器地址验证码登录 #方法2普通用户登录 传递参数driver #***************************************** #v2.0:app独立自动化测试 脚本--初始化登录 #优化面向过程的封装 #方法0手机驱动参数输出化设置 #方法1两个允许按钮服务器地址验证码登录 #方法2普通用户登录 #**************************************** #导入类库 import time from appium.webdriver.webdriver import WebDriver from appium.webdriver.webdriver import By #方法0手机驱动参数初始化 def test_cpas_init():# 手机参数初始化# ******************************************************************************************# 查询程序包名的命令:adb shell dumpsys activity activities| findstr mFocusedActivity#设置appPackage:被测程序包名caps {platformName: Android, # 设置platformName:手机系统名称AndroidplatformVersion: 7.1.2, # #设置platformVersion:手机系统版本deviceName: 127.0.0.1:52001, # 设置deviceName:设备名称appPackage: uni.UNI765428A, # 设置appPackage:被测程序包名appActivity: io.dcloud.PandoraEntry # 设置appActivity:被测程序活动名}# 启动appiumdriver WebDriver(http://127.0.0.1:4723/wd/hub, caps)# **********************************************************************************return driver#方法1两个允许按钮服务器地址验证码登录 def test_login_init(driver):#进行元素定位#点击允许按钮time.sleep(2)driver.find_element(By.ID,com.android.packageinstaller:id/permission_allow_button).click()#允许电话管理time.sleep(2)driver.find_element(By.ID,com.android.packageinstaller:id/permission_allow_button).click()#*****************************************************************#输入后台服务器地址time.sleep(5)xpath_service/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[1]/android.view.View/android.widget.EditTextservicepathhttps://lefeiwisdom-3pt-2t6a7-www.vip.51env.netdriver.find_element(By.XPATH,xpath_service).clear()time.sleep(1)driver.find_element(By.XPATH,xpath_service).send_keys(servicepath)#点击确定按钮time.sleep(3)#***********************************************************************xpath_ok/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[2]driver.find_element(By.XPATH,xpath_ok).click()#***********************************************************************#点击验证码登录按钮time.sleep(4)xpath_check/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[4]driver.find_element(By.XPATH,xpath_check).click()time.sleep(2)#********************************************************************************#方法2普通用户登录 def user_login_login(driver):#输入手机号码xpath_phone/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[5]/android.view.View/android.widget.EditText# id_phonec52abd0b-3c7b-4b6f-a2a0-f386d56bebd8driver.find_element(By.XPATH,xpath_phone).send_keys(13800138001)time.sleep(2)#输入验证码xpath_checkcode/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[6]/android.view.View/android.widget.EditTextdriver.find_element(By.XPATH,xpath_checkcode).send_keys(111111)#接受协议xpath_allow/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[9]time.sleep(2)driver.find_element(By.XPATH,xpath_allow).click()#登录按钮time.sleep(2)xpath_login/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[8]driver.find_element(By.XPATH,xpath_login).click()if __name__ __main__:drivertest_cpas_init()test_login_init(driver)user_login_login(driver) 4、test_loginV3.py    作者登录 #v3.0:app独立自动化测试 脚本--初始化登录 #优化面向过程的封装 #方法0手机驱动参数输出化设置 #方法1两个允许按钮服务器地址验证码登录 #方法3作者登录 #***************************************** #v3.0:app独立自动化测试 脚本--初始化登录 #优化面向过程的封装 #方法0手机驱动参数输出化设置 #方法1两个允许按钮服务器地址验证码登录 #方法3作者登录 #**************************************** #导入类库 import time from appium.webdriver.webdriver import WebDriver from appium.webdriver.webdriver import By #方法0手机驱动参数初始化 def test_cpas_init():# 手机参数初始化# ******************************************************************************************# 查询程序包名的命令:adb shell dumpsys activity activities| findstr mFocusedActivity#设置appPackage:被测程序包名caps {platformName: Android, # 设置platformName:手机系统名称AndroidplatformVersion: 7.1.2, # #设置platformVersion:手机系统版本deviceName: 127.0.0.1:52001, # 设置deviceName:设备名称appPackage: uni.UNI765428A, # 设置appPackage:被测程序包名appActivity: io.dcloud.PandoraEntry # 设置appActivity:被测程序活动名}# 启动appiumdriver WebDriver(http://127.0.0.1:4723/wd/hub, caps)# **********************************************************************************return driver#方法1两个允许按钮服务器地址验证码登录 def test_login_init(driver):#进行元素定位#点击允许按钮time.sleep(2)driver.find_element(By.ID,com.android.packageinstaller:id/permission_allow_button).click()#允许电话管理time.sleep(2)driver.find_element(By.ID,com.android.packageinstaller:id/permission_allow_button).click()#*****************************************************************#输入后台服务器地址time.sleep(5)xpath_service/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[1]/android.view.View/android.widget.EditTextservicepathhttps://lefeiwisdom-3pt-2t6a7-www.vip.51env.netdriver.find_element(By.XPATH,xpath_service).clear()time.sleep(1)driver.find_element(By.XPATH,xpath_service).send_keys(servicepath)#点击确定按钮time.sleep(3)#***********************************************************************xpath_ok/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[2]driver.find_element(By.XPATH,xpath_ok).click()#***********************************************************************#点击验证码登录按钮time.sleep(4)xpath_check/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[4]driver.find_element(By.XPATH,xpath_check).click()time.sleep(2)#********************************************************************************#方法3作者登录 def test_author_login(driver):time.sleep(5)#切换到作者登录标签xpath_author/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[3]driver.find_element(By.XPATH,xpath_author).click()time.sleep(2)#输入手机号码xpath_phone/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[5]/android.view.View/android.widget.EditText# id_phonec52abd0b-3c7b-4b6f-a2a0-f386d56bebd8driver.find_element(By.XPATH,xpath_phone).send_keys(13900139001)time.sleep(2)#输入验证码xpath_checkcode/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[6]/android.view.View/android.widget.EditTextdriver.find_element(By.XPATH,xpath_checkcode).send_keys(111111)#接受协议xpath_allow/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[9]time.sleep(2)driver.find_element(By.XPATH,xpath_allow).click()#登录按钮time.sleep(2)xpath_login/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[8]driver.find_element(By.XPATH,xpath_login).click()if __name__ __main__:drivertest_cpas_init()test_login_init(driver)test_author_login(driver) 5、test_loginV4.py #优化面向过程的封装,可选哪种方法的登录 #***************************************** #v4.0:app独立自动化测试 脚本--初始化登录 #优化面向过程的封装,可选哪种方法的登录 #方法0手机驱动参数输出化设置 #方法1两个允许按钮服务器地址验证码登录 #方法2普通用户登录/作者登录 #**************************************** #***************************************** #v4.0:app独立自动化测试 脚本--初始化登录 #优化面向过程的封装,可选哪种方法的登录 #方法0手机驱动参数输出化设置 #方法1两个允许按钮服务器地址验证码登录 #方法2普通用户登录/作者登录 #**************************************** #导入类库 import time from appium.webdriver.webdriver import WebDriver from appium.webdriver.webdriver import By #方法0手机驱动参数初始化 def test_cpas_init():# 手机参数初始化# ******************************************************************************************# 查询程序包名的命令:adb shell dumpsys activity activities| findstr mFocusedActivity#设置appPackage:被测程序包名caps {platformName: Android, # 设置platformName:手机系统名称AndroidplatformVersion: 7.1.2, # #设置platformVersion:手机系统版本deviceName: 127.0.0.1:52001, # 设置deviceName:设备名称appPackage: uni.UNI765428A, # 设置appPackage:被测程序包名appActivity: io.dcloud.PandoraEntry # 设置appActivity:被测程序活动名}# 启动appiumdriver WebDriver(http://127.0.0.1:4723/wd/hub, caps)# **********************************************************************************return driver#方法1两个允许按钮服务器地址验证码登录 def test_login_init(driver):#进行元素定位#点击允许按钮time.sleep(2)driver.find_element(By.ID,com.android.packageinstaller:id/permission_allow_button).click()#允许电话管理time.sleep(2)driver.find_element(By.ID,com.android.packageinstaller:id/permission_allow_button).click()#*****************************************************************#输入后台服务器地址time.sleep(5)xpath_service/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[1]/android.view.View/android.widget.EditTextservicepathhttps://lefeiwisdom-3pt-2t6a7-www.vip.51env.netdriver.find_element(By.XPATH,xpath_service).clear()time.sleep(1)driver.find_element(By.XPATH,xpath_service).send_keys(servicepath)#点击确定按钮time.sleep(3)#***********************************************************************xpath_ok/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[2]driver.find_element(By.XPATH,xpath_ok).click()#***********************************************************************#点击验证码登录按钮time.sleep(4)xpath_check/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[4]driver.find_element(By.XPATH,xpath_check).click()time.sleep(2)#********************************************************************************#方法2作者登录 def test_author_login(driver,usertype):time.sleep(5)if usertype1:#切换到作者登录标签xpath_author/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[3]driver.find_element(By.XPATH,xpath_author).click()userphone13900139001else:userphone13800138001time.sleep(2)#输入手机号码xpath_phone/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[5]/android.view.View/android.widget.EditText# id_phonec52abd0b-3c7b-4b6f-a2a0-f386d56bebd8driver.find_element(By.XPATH, xpath_phone).send_keys(userphone)time.sleep(2)#输入验证码xpath_checkcode/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[6]/android.view.View/android.widget.EditTextdriver.find_element(By.XPATH,xpath_checkcode).send_keys(111111)#接受协议xpath_allow/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[9]time.sleep(2)driver.find_element(By.XPATH,xpath_allow).click()#登录按钮time.sleep(2)xpath_login/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[8]driver.find_element(By.XPATH,xpath_login).click()if __name__ __main__:#进行哪种方法的登录#usertype0 表示普通用户登录1为作者登录usertypeint(input(请输入数字0 表示普通用户登录1为作者登录))drivertest_cpas_init()test_login_init(driver)test_author_login(driver,usertype) 6、test_loginV5.py #优化面向对象的封装,可选哪种方法的登录 #v5.0:app独立自动化测试 脚本--初始化登录 #优化面向对象的封装,可选哪种方法的登录 #方法0手机驱动参数输出化设置 #方法1两个允许按钮服务器地址验证码登录 #方法2普通用户登录/作者登录 #将以上方法封装到测试类中 #***************************************** #v5.0:app独立自动化测试 脚本--初始化登录 #优化面向对象的封装,可选哪种方法的登录 #方法0手机驱动参数输出化设置 #方法1两个允许按钮服务器地址验证码登录 #方法2普通用户登录/作者登录 #将以上方法封装到测试类中 #**************************************** #导入类库 import time from appium.webdriver.webdriver import WebDriver from appium.webdriver.webdriver import By class Test_login():#方法0手机驱动参数初始化def test_cpas_init(self):# 手机参数初始化# ******************************************************************************************# 查询程序包名的命令:adb shell dumpsys activity activities| findstr mFocusedActivity#设置appPackage:被测程序包名caps {platformName: Android, # 设置platformName:手机系统名称AndroidplatformVersion: 7.1.2, # #设置platformVersion:手机系统版本deviceName: 127.0.0.1:52001, # 设置deviceName:设备名称appPackage: uni.UNI765428A, # 设置appPackage:被测程序包名appActivity: io.dcloud.PandoraEntry # 设置appActivity:被测程序活动名}# 启动appiumdriver WebDriver(http://127.0.0.1:4723/wd/hub, caps)# **********************************************************************************return driver#方法1两个允许按钮服务器地址验证码登录def test_login_init(self,driver):#进行元素定位#点击允许按钮time.sleep(2)driver.find_element(By.ID,com.android.packageinstaller:id/permission_allow_button).click()#允许电话管理time.sleep(2)driver.find_element(By.ID,com.android.packageinstaller:id/permission_allow_button).click()#*****************************************************************#输入后台服务器地址time.sleep(5)xpath_service/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[1]/android.view.View/android.widget.EditTextservicepathhttps://lefeiwisdom-3pt-2t6a7-www.vip.51env.netdriver.find_element(By.XPATH,xpath_service).clear()time.sleep(1)driver.find_element(By.XPATH,xpath_service).send_keys(servicepath)#点击确定按钮time.sleep(3)#***********************************************************************xpath_ok/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[2]driver.find_element(By.XPATH,xpath_ok).click()#***********************************************************************#点击验证码登录按钮time.sleep(4)xpath_check/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[4]driver.find_element(By.XPATH,xpath_check).click()time.sleep(2)#********************************************************************************#方法2普通用户登录/作者登录def test_author_login(self,driver,usertype):time.sleep(5)if usertype1:#切换到作者登录标签xpath_author/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[3]driver.find_element(By.XPATH,xpath_author).click()userphone13900139001else:userphone13800138001time.sleep(2)#输入手机号码xpath_phone/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[5]/android.view.View/android.widget.EditText# id_phonec52abd0b-3c7b-4b6f-a2a0-f386d56bebd8driver.find_element(By.XPATH, xpath_phone).send_keys(userphone)time.sleep(2)#输入验证码xpath_checkcode/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[6]/android.view.View/android.widget.EditTextdriver.find_element(By.XPATH,xpath_checkcode).send_keys(111111)#接受协议xpath_allow/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[9]time.sleep(2)driver.find_element(By.XPATH,xpath_allow).click()#登录按钮time.sleep(2)xpath_login/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[8]driver.find_element(By.XPATH,xpath_login).click()if __name__ __main__:#进行哪种方法的登录#usertype0 表示普通用户登录1为作者登录usertypeint(input(请输入数字0 表示普通用户登录1为作者登录))#实例化测试类对象objTest_login()driverobj.test_cpas_init()obj.test_login_init(driver)obj.test_author_login(driver,usertype) 7、test_loginV6.py  将以上方法封装到测试类中,将参数变为属性 #***************************************** #v6.0:app独立自动化测试 脚本--初始化登录 #优化面向对象的封装,可选哪种方法的登录 #方法0手机驱动参数输出化设置 #方法1两个允许按钮服务器地址验证码登录 #方法2普通用户登录/作者登录 #将以上方法封装到测试类中,将参数变为属性 #**************************************** #***************************************** #v6.0:app独立自动化测试 脚本--初始化登录 #优化面向对象的封装,可选哪种方法的登录 #方法0手机驱动参数输出化设置 #方法1两个允许按钮服务器地址验证码登录 #方法2普通用户登录/作者登录 #将以上方法封装到测试类中,将参数变为属性 #**************************************** #导入类库 import time from appium.webdriver.webdriver import WebDriver from appium.webdriver.webdriver import By class Test_login():#方法0手机驱动参数初始化def test_cpas_init(self):# 手机参数初始化# ******************************************************************************************# 查询程序包名的命令:adb shell dumpsys activity activities| findstr mFocusedActivity#设置appPackage:被测程序包名caps {platformName: Android, # 设置platformName:手机系统名称AndroidplatformVersion: 7.1.2, # #设置platformVersion:手机系统版本deviceName: 127.0.0.1:52001, # 设置deviceName:设备名称appPackage: uni.UNI765428A, # 设置appPackage:被测程序包名appActivity: io.dcloud.PandoraEntry # 设置appActivity:被测程序活动名}# 启动appiumself.driver WebDriver(http://127.0.0.1:4723/wd/hub, caps)# **********************************************************************************#方法1两个允许按钮服务器地址验证码登录def test_login_init(self):#进行元素定位#点击允许按钮time.sleep(2)self.driver.find_element(By.ID,com.android.packageinstaller:id/permission_allow_button).click()#允许电话管理time.sleep(2)self.driver.find_element(By.ID,com.android.packageinstaller:id/permission_allow_button).click()#*****************************************************************#输入后台服务器地址time.sleep(5)xpath_service/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[1]/android.view.View/android.widget.EditTextservicepathhttps://lefeiwisdom-3pt-2t6a7-www.vip.51env.netself.driver.find_element(By.XPATH,xpath_service).clear()time.sleep(1)self.driver.find_element(By.XPATH,xpath_service).send_keys(servicepath)#点击确定按钮time.sleep(3)#***********************************************************************xpath_ok/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[2]self.driver.find_element(By.XPATH,xpath_ok).click()#***********************************************************************#点击验证码登录按钮time.sleep(4)xpath_check/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[4]self.driver.find_element(By.XPATH,xpath_check).click()time.sleep(2)#********************************************************************************#方法2普通用户登录/作者登录def test_author_login(self,usertype):time.sleep(5)if usertype1:#切换到作者登录标签xpath_author/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[3]self.driver.find_element(By.XPATH,xpath_author).click()userphone13900139001else:userphone13800138001time.sleep(2)#输入手机号码xpath_phone/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[5]/android.view.View/android.widget.EditText# id_phonec52abd0b-3c7b-4b6f-a2a0-f386d56bebd8self.driver.find_element(By.XPATH, xpath_phone).send_keys(userphone)time.sleep(2)#输入验证码xpath_checkcode/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[6]/android.view.View/android.widget.EditTextself.driver.find_element(By.XPATH,xpath_checkcode).send_keys(111111)#接受协议xpath_allow/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[9]time.sleep(2)self.driver.find_element(By.XPATH,xpath_allow).click()#登录按钮time.sleep(2)xpath_login/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View[8]self.driver.find_element(By.XPATH,xpath_login).click()if __name__ __main__:#进行哪种方法的登录#usertype0 表示普通用户登录1为作者登录usertypeint(input(请输入数字0 表示普通用户登录1为作者登录))#实例化测试类对象objTest_login()obj.test_cpas_init()obj.test_login_init()obj.test_author_login(usertype)
http://www.w-s-a.com/news/288463/

相关文章:

  • 高端响应式网站建设wordpress 全屏主题
  • 国内工程机械行业网站建设现状ui是什么意思
  • 成都网站开发哪家公司好出售家教网站模板
  • 订阅号做流量 那些电影如何链接网站温州市建设监理协会网站
  • 成都网站建设成功案例单招网商丘网站建设大全
  • 受欢迎的购物网站建设网推专员是做什么的
  • 商城网站前期准备湖南郴州建设局网站
  • 企业如何在自己的网站上做宣传外贸自建站可以自己做网站吗
  • 甘肃网站建设制作商网站空间哪家公司的好
  • 思途旅游网站建设系统用vscode做网站
  • 广州站改造最新消息半年工作总结ppt模板
  • logo模板下载网站推荐哪家网站开发培训好
  • 做外贸网站效果图页面关键词优化
  • 广平网站建设成都活动轨迹
  • 小型网站网站建设需要网络公司是什么行业
  • 滑动 手机网站 代码网页制作与设计讨论
  • 自己做网站处理图片用什么软件wordpress html5支持
  • 校园网站怎么建软文文案范文
  • 中国建设官方网站如何创建自己的软件
  • 来宾住房与城乡建设网站天津西青区怎么样
  • 西安网站建设培训班鄂州网页定制
  • 西部数码网站备份自己怎么做网站啊
  • h5网站开发用什么软件制作公司网站建设代理怎么做
  • 网站建设资料准备网上购物app有哪些
  • 沧州做网站优化哪家公司便宜国内百度云网站建设
  • 网站的最近浏览 怎么做龙岩市人才网最新招聘信息
  • 网站建设需要找工信部吗网站开发账务处理
  • 做那种的视频网站个体工商网站备案
  • 推广网官方推广网站中国建设招聘信息网站
  • 医院网站建设需要多少钱网络营销渠道可分为哪几种