appium class代码(参数为固定值)

作者在 2016-04-08 20:04:43 发布以下内容
#-*- coding:UTF-8 -*-  # 
'''
Created on 2016-4-8

@author: poptest
'''
import time
from appium import webdriver

class PublicFunClass(object):
    
    def addgoodsaddress(self):
        
        time.sleep(3)
        
        #登陆进去,点击头像、
        lee.find_element_by_id("com.subject.zhongchou:id/avatar_img").click()
        time.sleep(2)
        #点击地址
        lee.find_element_by_id("com.subject.zhongchou:id/address_layout").click()
        time.sleep(2)
        #点击添加地址按钮  
        lee.find_element_by_id("com.subject.zhongchou:id/add_address_btn").click()
        time.sleep(2)
        #进去后点击增加名字
        lee.find_element_by_id("com.subject.zhongchou:id/add_address_name_edit").send_keys(u"李小龙")
        time.sleep(2)
        #输入手机号
        lee.find_element_by_id("com.subject.zhongchou:id/add_address_tel_edit").send_keys("13613552859")
        time.sleep(2)
        #点击选择省份
        lee.find_element_by_id("android:id/text1").click()
        time.sleep(2)
        #滑屏坐标,上下滑屏
        lee.swipe(360, 1000, 360, 370, 500)
        time.sleep(2)
        #需要滑屏2次,才能找见需要的省份
        lee.swipe(360, 1000, 360, 370, 500)
        time.sleep(2)
        #找见山西,点击选择
        lee.find_element_by_android_uiautomator("new UiSelector().text(\"山西\")").click()
        time.sleep(2)
    #    选择城市
        lee.find_element_by_id("com.subject.zhongchou:id/add_address_city_name_text").click()
        time.sleep(2)
        #选择下表为2 的城市
        lee.find_elements_by_android_uiautomator("new UiSelector().className(\"android.widget.CheckedTextView\")")[2].click()
        time.sleep(2)
        #输入地址
        lee.find_element_by_id("com.subject.zhongchou:id/add_address_detail_edit").send_keys("suck my dick")
        time.sleep(1)
        #点击保存
        lee.find_element_by_id("com.subject.zhongchou:id/save_text").click()
    
    def login(self):
        
        time.sleep(5)
     
        
        lee.find_elements_by_id("com.subject.zhongchou:id/item_name")[1].click()
        time.sleep(3)
        
        #点击登录
        lee.find_element_by_id("com.subject.zhongchou:id/login_now_tv").click()
        time.sleep(3)
        print "fuck1"
        #    输入手机号
        lee.find_element_by_id("com.subject.zhongchou:id/loginnumber_phones").send_keys("13613552859")
        time.sleep(2)
        #    输入密码
        lee.find_element_by_id("com.subject.zhongchou:id/loginnumber_password").send_keys("111111")
        time.sleep(2)
        lee.find_element_by_id("com.subject.zhongchou:id/go_numberlogin").click()
        
    def enterApp(self):
        global lee #lee必须在此声明,如果放在其他地方声明失败
        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地址和端口号      
        lee = webdriver.Remote("http://127.0.0.1:4723/wd/hub",descried_caps)
#-*- coding:UTF-8 -*-  # 调用class
'''
Created on 2016-4-8

@author: poptest
'''
import time
from appium import webdriver
from publicfunction import PublicFunClass
P = PublicFunClass.PublicFunClass()  #类的实例化
P.enterApp()
time.sleep(2)
P.login()
time.sleep(2)
P.addgoodsaddress()
appium | 阅读 10984 次
文章评论,共0条
游客请输入验证码
浏览2354378次