Exemple #1
0
 def __init__(self, driver):
     super().__init__(driver)
     if GlobalVar.get_platform() == GlobalVar.IOS:
         from src.eufyhome.ios.app.AllShareActivity import AllShareActivity
     else:
         from src.eufyhome.android.app.AllShareActivity import AllShareActivity
     global Page
     Page = AllShareActivity()
 def get_phone(self, param):
     """
     读取电话
     :param param:
     :return:
     """
     if GlobalVar.get_platform() == GlobalVar.IOS:
         param = param + '_ios'
     else:
         param = param + '_a'
     return self.cf.get('callus', param)
 def __init__(self, driver):
     self.driver = driver
     self.platform = GlobalVar.get_platform()
Exemple #4
0
def driver_setup(request):
    """
    创建会话
    scope=class时使用cls,scope=function时使用instance
    :param request:
    :return:
    """
    global driver, device_sn, device_name, platform_version, wda_port, system_port, appium_port
    if GlobalVar.get_platform() == GlobalVar.IOS:
        desired_capabilities = {
            'automationName': 'XCUITest',
            'platformName': 'ios',
            'udid': device_sn,
            'deviceName': device_name,
            'platformVersion': platform_version,
            'wdaLocalPort': wda_port,
            'bundleId': data.get_eufyhome('bundleId'),
            'newCommandTimeout': 600,
            'clearSystemFiles': True,
            'excludeDriverLogs': ['syslog', 'server'],
            'iosInstallPause': 8000,
            'wdaLaunchTimeout': 600000,
            'wdaConnectionTimeout': 600000,
            'wdaStartupRetries': 4,
            'wdaStartupRetryInterval': 60000,
            'orientation': 'PORTRAIT',
            'noReset': True,
            'fullReset': False,
            'autoLaunch': True
        }
    elif GlobalVar.get_platform() == GlobalVar.ANDROID:
        desired_capabilities = {
            'automationName': 'UiAutomator2',
            'uiautomator2ServerInstallTimeout': 120000,  # ms
            'uiautomator2ServerLaunchTimeout': 120000,  # ms
            'platformName': 'Android',
            'platformVersion': '9.0',
            'udid': device_sn,
            'deviceName': 'Android',
            'appPackage': 'com.eufylife.smarthome',
            'appActivity': 'com.oceanwing.eufyhome.main.WelcomeActivity',
            'newCommandTimeout': 600,
            'adbExecTimeout': 120000,  # ms
            'systemPort': system_port,
            'orientation': 'PORTRAIT',
            'noReset': True,  # 是否以初始状态启动app
            'fullReset': False,  # 是否重装app
            'autoLaunch': True  # app自动启动

            # 自动获取元素的配置
            # 'noReset': True,
            # 'fullReset': False,
            # 'autoLaunch': False
        }

    request.instance.driver = webdriver.Remote(command_executor='http://{}:{}/wd/hub'.format('127.0.0.1', appium_port),
                                             desired_capabilities=desired_capabilities)  # 创建会话
    driver = request.instance.driver
    time.sleep(10)

    def teardown():
        try:
            driver.quit()  # 测试结束后结束本次会话
        except Exception as e:
            print(e)
            pass

    request.addfinalizer(teardown)