Exemple #1
0
def start_moniqi(p_name):
    os.system(r'.\start_moniqi.bat')
    time.sleep(10)
    if judgeProcess(p_name):
        connect_deiver()
    else:
        logs.error('device is False')
Exemple #2
0
    def find_element(self, *loc):

        try:
            WebDriverWait(self.driver, 20).until(EC.visibility_of_element_located(loc)) # 显示等待
            return self.driver.find_element(*loc)
        except Exception as e:
            logs.error('页面未找到%s元素' % loc)
Exemple #3
0
    def get_H5element(self, cont):

        # H5上下文
        contexts = self.driver.contexts
        logs.info('contexts:', contexts)

        # 切换进webview视图
        if cont in contexts:
            self.driver.switch_to.context(cont)
            return True
        else:
            logs.error('没有找到对应webview!')
            return False
Exemple #4
0
    def get_driver(self):
        data = self.conf.get_yamlfile()
        try:
            # appium配置信息
            desired_caps = {}
            desired_caps['platformName'] = data['platformName']
            desired_caps['platformVersion'] = data['platformVersion']
            desired_caps['deviceName'] = data['deviceName']

            # 获取APP的路径,然后导入
            # base_dir = os.path.dirname(os.path.dirname(__file__))
            # app_path = os.path.join(base_dir, 'app', data['appname'])
            # desired_caps['appname'] = app_path

            # 直接导入APP
            desired_caps['app'] = data['app']

            # 启动APP的activity
            desired_caps['appPackage'] = data['appPackage']
            desired_caps['appActivity'] = data['appActivity']

            # 测试覆盖开关按钮
            desired_caps['noReset'] = data['noReset']

            # 开启中文输入
            desired_caps['unicodeKeyboard'] = data['unicodeKeyboard']
            desired_caps['resetKeyboard'] = data['resetKeyboard']

            # 开启验证Toast信息
            desired_caps['automationName'] = data['automationName']

            # 设置命令超时时间
            # desired_caps['newCommandTimeout'] = data['newCommandTimeout']

            logs.info('start app...')
            driver = webdriver.Remote(
                'http://%s:%s/wd/hub' % (data['ip'], data['port']),
                desired_caps)
            # driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
            driver.implicitly_wait(10)
            return driver

        except Exception as e:
            logs.error('Appium服务未启动或设备devices未连接!', e)
            exit()
Exemple #5
0
 def get_value(self, sec_name, opt_name):
     try:
         return self.conf.get(sec_name, opt_name)
     except Exception as e:
         logs.error(e)