APP UI層自動化測試--基於appium
阿新 • • 發佈:2019-02-01
import pytest import time from appium import webdriver class Testfangdongliqi: u'測試登入' def setup_class(self): desired_caps = {} desired_caps['platformName'] = 'Android' desired_caps['platformVersion'] = '4.4.2' desired_caps['deviceName'] = '022GPLDU3A010372' desired_caps['appPackage'] = 'prancent.project.rentalhouse.app' desired_caps['appActivity'] = '.activity.WelComeActivity' desired_caps['unicodeKeyboard']=True desired_caps['resetKeyboard']=True self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps) time.sleep(1) def teardown_class(self): self.driver.quit() def edittextclear(self): #刪除密碼框字元 self.driver.keyevent(123) for i in range(0,16): self.driver.keyevent(67) def test_a_login(self): u'使用者名稱、密碼為空登入' if self.driver.find_elements_by_name('我'): self.driver.find_element_by_id('rl_barme').click() self.driver.find_element_by_id('ll_nickname').click() self.driver.find_element_by_id('tv_login_out').click() self.driver.find_element_by_id('activity_login_user_edt').clear() self.driver.find_element_by_id('activity_login_center_btn').click() self.driver.implicitly_wait(5) print (u'使用者名稱、密碼為空不能登入') else: self.driver.find_element_by_id('activity_login_user_edt').clear() self.driver.find_element_by_id('activity_login_password_edt').click() self.edittextclear() self.driver.find_element_by_id('activity_login_center_btn').click() self.driver.implicitly_wait(5) if not self.driver.find_elements_by_id('iv_barindex'): print (u'使用者名稱、密碼為空不能登入')