基于Appium、Python的自動化測試環境部署和實踐(6)

發表于:2017-04-20來源:cnblogs作者:bacon劉點擊數: 標簽:pythonAppium
from appium import webdriver import time from selenium.common.exceptions import NoSuchElementException class driverObject: def __init__(self, host, port, platform, version, deviceName, noReset, unicod
復制代碼
from appium import webdriver import time from selenium.common.exceptions import NoSuchElementException class driverObject: def __init__(self, host, port, platform, version, deviceName, noReset, unicodeK, resetK, appPath ,appP_bdId, appA_udid, localPort): #__appP_bdId = "com.yitong.fjnx.mbank.android"
        __appP_bdId = appP_bdId #__appA_udid = ".Splash"
        __appA_udid = appA_udid self.pwmode = 'lower' self.model='Appium' self.desired_caps = {} self.desired_caps['platformName'] = platform self.desired_caps['platformVersion'] = version self.desired_caps['noReset'] = noReset self.desired_caps['unicodeKeyboard'] = unicodeK self.desired_caps['resetKeyboard'] = resetK self.desired_caps['app'] = appPath self.desired_caps['udid'] = deviceName self.desired_caps['deviceName'] = deviceName # Android - ignored, iOS - iPhone name
        if platform == "Android": self.desired_caps['appPackage'] = __appP_bdId self.desired_caps['appActivity'] = __appA_udid
        if platform == "iOS": self.desired_caps['bundleId'] = __appP_bdId self.desired_caps['automationName'] = 'XCUITest' self.desired_caps['wdaLocalPort'] = localPort url = "http://" + host + ":" + str(port) + "/wd/hub" self.driver = webdriver.Remote(url, self.desired_caps) time.sleep(5) def get_driver(self): return self.driver def quit(self): self.driver.quit()
復制代碼
主類
復制代碼
from testClass import driverObject if __name__ == '__main__': driver = driverObject(參數...)   ele = self.driver.find_elements_by_class_name("android.widget.Button") ele[0].click() time.sleep(5) ele = self.driver.find_elements_by_class_name("android.widget.EditText") ele[1].send_keys("account") ele[2].send_keys("password") ele = self.driver.find_elements_by_class_name("android.widget.Button") time.sleep(2) ele[0].click() driver.quit()
復制代碼
 關于Appium、Python的測試腳本公共函數可以查閱Appium-Python-Api文檔,里面記錄Appium提供給python的公共函數。其實,測試腳本的大部分內容就是找控件、點擊控件、輸入內容、線程等待這些操作。
 

原文轉自:http://www.cnblogs.com/baconLiu/p/6735441.html

...

熱門標簽

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97