def get_platformVersion(self): values = os.popen(self.get_Version).readlines() if values != '': Version = values[0].split('=')[1] log.info('手机版本号为:' + Version) return Version.strip() else: log.warn('暂未获取到手机设备')
def test_2addstore(self): log.info('开始新增终端门店') common.get_id( 'com.fiberhome.waiqin365.client:id/cm_topbar_tv_right').click() common.get_name('点击输入').send_keys('test-APP') common.get_name('提交').click() common.page('工作台')
def get_deviceName(self): values = os.popen(self.get_device).readlines() dev = values[1].split()[0] if len(values) - 2 == 1: log.info('手机设备为:' + dev) return dev else: log.warn('暂未获取到手机设备')
def get_toast(self, toast): try: message = '//*[contains(@text,\'{}\')]'.format(toast) element = WebDriverWait(self.driver, 5, 0.5).until( EC.presence_of_element_located((By.XPATH, message))) log.info('查找到toast:'+'%s'%(element.text)) except: log.error('未查找到toast:'+'%s'%(toast))
class visit_temp(unittest.TestCase): log = log() log.info(u'开始高级拜访的测试') @classmethod def setUpClass(cls): cls.driver = common.login() @classmethod def tearDownClass(cls): cls.driver.quit() def setUp(self): pass def tearDown(self): pass def test_1launchvisit(self): common.get_name('高级拜访').click() try: self.assertTrue(common.find_name(u'临时拜访')) except Exception, e: print e log.error('进入高级拜访模块失败') common.screenshot("launchvisit.png")
class visit_temp(unittest.TestCase): log = log() log.info(u'开始客户管理列表部分的测试') @classmethod def setUpClass(cls): cls.driver=common.login() @classmethod def tearDownClass(cls): cls.driver.quit() def setUp(self): pass def tearDown(self): pass def test_1launchstore(self): # a = "//*[@text='%s']"%('终端门店') # self.driver.find_element_by_xpath(a).click() common.screenshot(u'工作台.png') common.get_name('终端门店').click() time.sleep(2)
class store_list(unittest.TestCase): log = log() log.info(u'开始客户管理列表部分的测试') @classmethod def setUpClass(cls): cls.driver = common.login() @classmethod def tearDownClass(cls): cls.driver.quit() def setUp(self): pass def tearDown(self): pass def test_1launchstore(self): common.screenshot(u'工作台.png') common.get_name('终端门店').click() def test_2addstore(self): log.info('开始新增终端门店') common.get_id( 'com.fiberhome.waiqin365.client:id/cm_topbar_tv_right').click() common.get_name('点击输入').send_keys('test-APP') common.get_name('提交').click() common.page('工作台')
def send_email(): mail = get_mail() message = MIMEText(mail, 'html', 'utf-8') message['From'] = Header("爱学习的圈圈", 'utf-8') # message['To'] = Header("圈圈", 'utf-8') message['Subject'] = Header('UI自动化测试报告', 'utf-8') try: server = smtplib.SMTP_SSL("smtp.qq.com", 465) # 发件人第三方SMTP服务器,端口是465 server.login(mail_user, mail_pass) server.sendmail(sender, receiver, message.as_string()) server.quit() log.info('邮件发送成功') # print("邮件发送成功") except smtplib.SMTPException: log.error('邮件发送失败')
log = log() <<<<<<< HEAD driver.find_element_by_id("com.waka:id/edt_login_email").send_keys("*****@*****.**") ======= driver.find_element_by_id("com.waka:id/edt_login_email").send_keys("*****@*****.**") >>>>>>> waka driver.find_element_by_id("com.waka:id/edt_login_password").send_keys("123") driver.find_element_by_id("com.waka:id/btn_login").click() def get_Toast(message): try: mes = '//*[contains(@text,\'{}\')]'.format(message) element = WebDriverWait(driver, 5, 0.5).until( EC.presence_of_element_located((By.XPATH, mes))) <<<<<<< HEAD log.info('查找到tost:'+'%s'%(message)) except: log.error('没有查找到toast:'+'%s'%(message)) get_Toast(u'该邮箱未注册') ======= log.info('查找到toast:'+'%s'%(element.text)) except: log.error('没有查找到toast:'+'%s'%(message)) get_Toast(u'密码错误') >>>>>>> waka
from common.logs import log log = log() conf = Readconfig() cmd = devices() deviceName = cmd.get_deviceName() platformVersion = cmd.get_platformVersion() platformName = conf.getAppValue('platformName') appPackage = conf.getAppValue('appPackage') appActivity = conf.getAppValue('appActivity') desired_caps = {} desired_caps['deviceName'] = '%s' % deviceName desired_caps['platformName'] = '%s' % platformName desired_caps['platformVersion'] = '%s' % platformVersion desired_caps['appPackage'] = '%s' % appPackage desired_caps['appActivity'] = '%s' % appActivity desired_caps['unicodeKeyboard'] = True desired_caps['resetKeyboard'] = True desired_caps['no-reset'] = True try: driver = webdriver.Remote(command_executor="http://127.0.0.1:4723/wd/hub", desired_capabilities=desired_caps) time.sleep(5) log.info('获取driver成功') except WebDriverException: log.warn('获取driver失败') # print('No driver')