作者在 2016-04-09 20:44:24 发布以下内容
#-*- coding:UTF-8 -*- #
'''
Created on 2016-4-8
@author: poptest
'''
import time
from appium import webdriver
class CommonFunction(object):
#接收用户名、电话、地址
def addgoodsaddress(self,revName,revTel,revAddr):
time.sleep(3)
#点击头像、登陆进去
dr.find_element_by_id("com.subject.zhongchou:id/avatar_img").click()
time.sleep(2)
#点击收货地址
dr.find_element_by_id("com.subject.zhongchou:id/address_layout").click()
time.sleep(2)
#点击添加收货地址
#dr.find_element_by_id("com.subject.zhongchou:id/add_address_btn").click()
dr.find_element_by_android_uiautomator("new UiSelector().text(\"添加收货地址\")").click()
time.sleep(2)
#收件人
dr.find_element_by_id("com.subject.zhongchou:id/add_address_name_edit").send_keys(revName)
time.sleep(2)
#输入手机号
dr.find_element_by_id("com.subject.zhongchou:id/add_address_tel_edit").send_keys(revTel)
time.sleep(2)
#点击选择省份
dr.find_element_by_id("android:id/text1").click()
time.sleep(2)
#滑屏坐标,上下滑屏 需要滑屏次,才能找见需要的省份
dr.swipe(400,70,460,0,500)
time.sleep(2)
dr.swipe(460,1200,460,200,500)
time.sleep(2)
dr.swipe(460,1200,460,200,500)
time.sleep(2)
#找见北京,点击选择
dr.find_element_by_android_uiautomator("new UiSelector().text(\"北京\")").click()
time.sleep(2)
#选择市区
dr.find_element_by_id("com.subject.zhongchou:id/add_address_city_name_text").click()
time.sleep(2)
dr.swipe(400,1050,400,350,500)
#找见昌平区
dr.find_element_by_android_uiautomator("new UiSelector().text(\"昌平区\")").click()
#输入地址
dr.find_element_by_id("com.subject.zhongchou:id/add_address_detail_edit").send_keys(revAddr)
time.sleep(1)
#点击保存
dr.find_element_by_id("com.subject.zhongchou:id/save_text").click()
#接收电话、密码
def exit(self):
dr.quit()
def login(self,revTel,revPsd):
#点击我
dr.find_elements_by_id("com.subject.zhongchou:id/item_name")[1].click()
time.sleep(3)
#点击马上登录
dr.find_element_by_id("com.subject.zhongchou:id/login_now_tv").click()
time.sleep(3)
#输入手机号
dr.find_element_by_id("com.subject.zhongchou:id/loginnumber_phones").send_keys(revTel)
time.sleep(2)
#输入密码
dr.find_element_by_id("com.subject.zhongchou:id/loginnumber_password").send_keys(revPsd)
time.sleep(2)
#点击登录
dr.find_element_by_id("com.subject.zhongchou:id/go_numberlogin").click()
def enterApp(self):
global dr
descried_caps={}
#设置输入法
descried_caps["unicodeKeyboard"] = "True"
descried_caps["resetKeyboard"] = "True"
#传输设备号
descried_caps['device']='2014813'
descried_caps['platformName']='Android'
descried_caps['deviceName']='HM2014813'
descried_caps['version']='5.1'
#找见appium的IP地址和端口号
dr = webdriver.Remote("http://127.0.0.1:4723/wd/hub",descried_caps)
time.sleep(5)
'''
Created on 2016-4-8
@author: poptest
'''
import time
from appium import webdriver
class CommonFunction(object):
#接收用户名、电话、地址
def addgoodsaddress(self,revName,revTel,revAddr):
time.sleep(3)
#点击头像、登陆进去
dr.find_element_by_id("com.subject.zhongchou:id/avatar_img").click()
time.sleep(2)
#点击收货地址
dr.find_element_by_id("com.subject.zhongchou:id/address_layout").click()
time.sleep(2)
#点击添加收货地址
#dr.find_element_by_id("com.subject.zhongchou:id/add_address_btn").click()
dr.find_element_by_android_uiautomator("new UiSelector().text(\"添加收货地址\")").click()
time.sleep(2)
#收件人
dr.find_element_by_id("com.subject.zhongchou:id/add_address_name_edit").send_keys(revName)
time.sleep(2)
#输入手机号
dr.find_element_by_id("com.subject.zhongchou:id/add_address_tel_edit").send_keys(revTel)
time.sleep(2)
#点击选择省份
dr.find_element_by_id("android:id/text1").click()
time.sleep(2)
#滑屏坐标,上下滑屏 需要滑屏次,才能找见需要的省份
dr.swipe(400,70,460,0,500)
time.sleep(2)
dr.swipe(460,1200,460,200,500)
time.sleep(2)
dr.swipe(460,1200,460,200,500)
time.sleep(2)
#找见北京,点击选择
dr.find_element_by_android_uiautomator("new UiSelector().text(\"北京\")").click()
time.sleep(2)
#选择市区
dr.find_element_by_id("com.subject.zhongchou:id/add_address_city_name_text").click()
time.sleep(2)
dr.swipe(400,1050,400,350,500)
#找见昌平区
dr.find_element_by_android_uiautomator("new UiSelector().text(\"昌平区\")").click()
#输入地址
dr.find_element_by_id("com.subject.zhongchou:id/add_address_detail_edit").send_keys(revAddr)
time.sleep(1)
#点击保存
dr.find_element_by_id("com.subject.zhongchou:id/save_text").click()
#接收电话、密码
def exit(self):
dr.quit()
def login(self,revTel,revPsd):
#点击我
dr.find_elements_by_id("com.subject.zhongchou:id/item_name")[1].click()
time.sleep(3)
#点击马上登录
dr.find_element_by_id("com.subject.zhongchou:id/login_now_tv").click()
time.sleep(3)
#输入手机号
dr.find_element_by_id("com.subject.zhongchou:id/loginnumber_phones").send_keys(revTel)
time.sleep(2)
#输入密码
dr.find_element_by_id("com.subject.zhongchou:id/loginnumber_password").send_keys(revPsd)
time.sleep(2)
#点击登录
dr.find_element_by_id("com.subject.zhongchou:id/go_numberlogin").click()
def enterApp(self):
global dr
descried_caps={}
#设置输入法
descried_caps["unicodeKeyboard"] = "True"
descried_caps["resetKeyboard"] = "True"
#传输设备号
descried_caps['device']='2014813'
descried_caps['platformName']='Android'
#-*- coding:UTF-8 -*- #
'''
Created on 2016-4-8
@author: poptest
'''
import unittest,time
from ShareLibModel import CommonFunction33
P = CommonFunction33.CommonFunction()
class Test(unittest.TestCase):
def setUp(self):
P.enterApp()
def tearDown(self):
P.exit()
def testLogin(self):
P.login("18513253584","111111")
time.sleep(2)
P.addgoodsaddress(u"小红","18513253584",u"北京市昌平区")
def testAddr(self):
P.login("18513253584","111111")
time.sleep(2)
P.addgoodsaddress(u"王亚萍","18513253584",u"北京市昌平区")
#流程为setup-testAddr-teardown,第二遍执行setup-testLogin-teardown.
if __name__ == "__main__":
#import sys;sys.argv = ['', 'Test.testName']
unittest.main()
descried_caps['deviceName']='HM2014813'
descried_caps['version']='5.1'
#找见appium的IP地址和端口号
dr = webdriver.Remote("http://127.0.0.1:4723/wd/hub",descried_caps)
time.sleep(5)