Exemple #1
0
def driver_booking(request, session_booking):
    driver = WebDriverManager.get_instance().driver
    driver.implicitly_wait(10)
    platform = WebDriverManager.get_instance().device.platform

    if platform == "Android":
        result = driver.execute_script(
            "mobile: shell",
            {'command': "dumpsys window windows | grep -E 'mCurrentFocus'"})
        locale = driver.execute_script(
            "mobile: shell", {'command': "getprop persist.sys.locale"})
        app_package = result.split("/")[0].split(" ")[-1]
        set_settings("Android", "package", app_package)
        set_settings("Android", "locale", locale.split("-")[0])
    else:
        locale = subprocess.run([
            "ideviceinfo -u {} -q com.apple.international -k Locale".format(
                WebDriverManager.get_instance().device.udid)
        ],
                                shell=True,
                                stdout=PIPE,
                                stderr=PIPE).stdout
        set_settings("Android", "locale", locale.decode().split("_")[0])

    set_settings("System", "platform", platform)
    yield driver
    WebDriverManager.destroy()
Exemple #2
0
def driver(request, session):
    logging.info("[session] starting driver")
    if not request.config.getoption("--simulator"):
        unlock(request.config.getoption("--device-id"))
    driver = WebDriverManager.get_instance().driver
    driver.implicitly_wait(10)
    platform = WebDriverManager.get_instance().device.platform

    if platform == "Android":
        result = driver.execute_script("mobile: shell", {
            'command': "dumpsys window windows | grep -E 'mObscuringWindow|mHoldScreenWindow|mCurrentFocus' | grep -E 'mapswithme'"})
        locale = driver.execute_script("mobile: shell", {'command': "getprop persist.sys.locale"})
        if locale == "\n":
            locale = "en-US"
        app_package = result.split("/")[0].split(" ")[-1]
        set_settings("Android", "package", app_package)
        set_settings("Android", "locale", locale.split("-")[0])
    else:
        if WebDriverManager.get_instance().device.emulator:
            locale = b'ru_RU'
        else:
            locale = subprocess.run(["ideviceinfo -u {} -q com.apple.international -k Locale"
                                    .format(WebDriverManager.get_instance().device.udid)],
                                    shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout
        set_settings("Android", "locale", locale.decode().split("_")[0])
        # ideviceinstaller -U <UUID> -l | grep maps.me

    set_settings("Tests", "routing_time", request.config.getoption("--time"))
    set_settings("System", "platform", platform)
    yield driver
    WebDriverManager.destroy()
Exemple #3
0
 def driver(self, request):
     unlock(request.config.getoption("--device-id"))
     driver = WebDriverManager.get_instance().driver
     driver.implicitly_wait(30)
     platform = WebDriverManager.get_instance().device.platform
     set_settings("System", "platform", platform)
     result = driver.execute_script("mobile: shell", {'command': "dumpsys window windows | grep -E 'mCurrentFocus'"})
     locale = driver.execute_script("mobile: shell", {'command': "getprop persist.sys.locale"})
     app_package = result.split("/")[0].split(" ")[-1]
     set_settings("Android", "package", app_package)
     set_settings("Android", "locale", locale.split("-")[0])
     yield driver
     try:
         WebDriverManager.destroy()
     except (InvalidSessionIdException, WebDriverException):
         logging.info("Session deleted by timeout")