def click_shop_pwd_title(self, verify=True): logger.info('点击"商户密码登录"标签') self.driver.click(self.shop_pwd_title) self.assertTrue( self.driver.element_is_show(self.remember_pwd), "记住密码按钮未显示" ) if verify else None
def click_phone_code_title(self, verify=True): logger.info('点击"手机验证码登录"标签') self.driver.click(self.phone_code_title) self.assertTrue( self.driver.element_is_show(self.phone_code), "获取验证码按钮未显示" ) if verify else None
def kill_appium(): """ kill掉所有node.exe进程 :return: """ arg = 'taskkill -F -IM node.exe' r = run_cmd(arg) logger.info(r.strip())
def get_udids(): """ 得到连接的设备的udid :return: list """ stdout = run_cmd('adb devices') logger.debug('adb devices的结果{}'.format(stdout)) udids = re.findall(r'\n(.+)\tdevice', stdout) logger.info('udids{}'.format(udids)) return udids
def start_appium(udids, ports): """ 依据设备udid和得到的端口号启动对应数量的appium服务 :param udids: 设备的idid,type:list :param ports: 空闲的端口号,type:list :return: """ k = 0 for udid in udids: arg = ('appium -p {} -bp {} --chromedriver-port {} -U {} --session-override --log-timestamp' ' --local-timezone').format(ports[k], ports[k+1], ports[k+2], udid) logger.info('开始启动appium服务{}'.format(arg)) th = threading.Thread(target=run_server, args=(arg, udid)) th.start() # 这里不需要join,runcase运行完毕杀掉appium服务相关进程即可 k += 3
def get_ports(udids): """ 依据得到的设备数生成未使用的端口号,udid * 4 :return: list """ udids_num = len(udids) ports = list() port = 4724 while True: if len(ports) == udids_num * 4: break if not run_cmd('netstat -ano | findstr {}'.format(port)): ports.append(port) port += 1 logger.info('得到未使用的端口列表:{}'.format(ports)) return ports
def click_phone_code(self): logger.info('点击"获取验证码"') self.driver.click(self.phone_code)
def send_keys_phone_pwd(self, pwd): logger.info('验证码输入框输入{}'.format(pwd)) self.driver.send_keys(self.phone_pwd, pwd)
def send_keys_phone_name(self, phone_number): logger.info('手机号输入框输入{}'.format(phone_number)) self.driver.send_keys(self.phone_name, phone_number)
def click_rem_pwd(self): logger.info('点击"记住密码"') self.driver.click(self.remember_pwd)
def check_rem_pwd_checked(self): status = self.driver.get_attribute(self.remember_pwd, 'checked') logger.info('记住密码框勾选:{}'.format(status)) return status
def click_login_btn(self, verify=True): logger.info('点击"立即登录"') self.driver.click(self.login_btn)
def send_keys_login_pwd(self, pwd='xxxxxx'): logger.info('密码输入框输入{}'.format(pwd)) self.driver.send_keys(self.login_pwd, pwd)
def send_keys_login_name(self, username='******'): logger.info('用户名输入框输入{}'.format(username)) self.driver.send_keys(self.login_name, username)