Beispiel #1
0
def restore_window_from_taskbar(option=None):
    """Restore firefox from task bar."""
    if OSHelper.is_mac():
        try:
            click(Pattern("main_menu_window.png"))
            if option == "browser_console":
                click(Pattern("window_browser_console.png"))
            else:
                click(Pattern("window_firefox.png"))
        except FindError:
            raise APIHelperError("Restore window from taskbar unsuccessful.")
    elif OSHelper.get_os_version() == "win7":
        try:
            click(Pattern("firefox_start_bar.png"))
            if option == "library_menu":
                click(Pattern("firefox_start_bar_library.png"))
            if option == "browser_console":
                click(Pattern("firefox_start_bar_browser_console.png"))
        except FindError:
            raise APIHelperError("Restore window from taskbar unsuccessful.")

    else:
        type(text=Key.TAB, modifier=KeyModifier.ALT)
        if OSHelper.is_linux():
            Mouse().move(Location(0, 50))
    time.sleep(Settings.DEFAULT_UI_DELAY)
Beispiel #2
0
 def create_email_subject(target):
     email_info = "[%s][%s]Iris Test Report %s" % (
         target.target_name + " " + str(target.values["fx_version"])
         if target.target_name == "Firefox" else target.target_name,
         OSHelper.get_os_version().capitalize(),
         date.today(),
     )
     return email_info
Beispiel #3
0
def delete_selected_file():
    """Delete selected file/files inside a folder."""
    if OSHelper.is_mac():
        type(text=Key.BACKSPACE, modifier=KeyModifier.CMD)
    elif OSHelper.get_os_version() == 'win7':
        type(text=Key.DELETE)
        type(text='y')
    else:
        type(text=Key.DELETE)
Beispiel #4
0
def create_run_log(app):
    args = get_core_args()
    meta = {
        "run_id":
        PathManager.get_run_id(),
        "platform":
        OSHelper.get_os().value,
        "config":
        "%s, %s-bit, %s" % (OSHelper.get_os_version(), OSHelper.get_os_bits(),
                            OSHelper.get_processor()),
        "locale":
        args.locale,
        "args":
        " ".join(sys.argv),
        "params":
        vars(args),
        "log":
        os.path.join(PathManager.get_current_run_dir(), "iris_log.log"),
    }
    values = {}
    for i in app.values:
        values[i] = app.values[i]
    meta["values"] = values

    meta["iris_version"] = 2.0
    try:
        repo = git.Repo(PathManager.get_module_dir())
        meta["iris_repo"] = repo.working_tree_dir
        try:
            meta["iris_branch"] = repo.active_branch.name
        except:
            # If we're on a detached head, the active_branch is
            # undefined and raises an exception. This at least
            # allows the test run to finish
            meta["iris_branch"] = "detached"
        meta["iris_branch_head"] = repo.head.object.hexsha
    except:
        # Iris is not running in a Git repo, so don't try to
        # report on non-existent data.
        meta["iris_repo"] = "n/a"
        meta["iris_branch"] = "n/a"
        meta["iris_branch_head"] = "n/a"

    meta["python_version"] = get_python_version()

    failed = 0
    passed = 0
    skipped = 0
    errors = 0

    for test in app.completed_tests:
        if test.outcome == "FAILED":
            failed = failed + 1
        if test.outcome == "PASSED":
            passed = passed + 1
        if test.outcome == "SKIPPED":
            skipped = skipped + 1
        if test.outcome == "ERROR":
            errors = errors + 1

    logger.debug("Updating run.json with completed run data.")
    meta["total"] = len(app.completed_tests)
    meta["passed"] = passed
    meta["failed"] = failed
    meta["skipped"] = skipped
    meta["errors"] = errors
    meta["start_time"] = app.start_time
    meta["end_time"] = app.end_time
    meta["total_time"] = app.end_time - app.start_time

    tests = {
        "all_tests": convert_test_list(app.completed_tests),
        "failed_tests": convert_test_list(app.completed_tests,
                                          only_failures=True),
        "flaky_tests": app.flaky_tests,
    }

    run_file = os.path.join(PathManager.get_current_run_dir(), "run.json")
    run_file_data = {"meta": meta, "tests": tests}

    with open(run_file, "w") as f:
        json.dump(run_file_data, f, sort_keys=True, indent=True)
Beispiel #5
0
def _get_image_path(caller, image: str) -> str:
    """Enforce proper location for all Pattern creation.

    :param caller: Path of calling Python module.
    :param image: String filename of image.
    :return: Full path to image on disk.

    We will look at all possible paths relative to the calling file, with this priority:

    - current platform locale folder
    - common locale folder
    - current platform root
    - common root

    Each directory is scanned for four possible file names, depending on resolution.
    If we find nothing, we will raise an exception.
    """

    module = os.path.split(caller)[1]
    module_directory = os.path.split(caller)[0]
    file_name = image.split(".")[0]
    names = [image, "*****@*****.**" % file_name]

    if OSHelper.get_os_version() == "win7":
        os_version = "win7"
    else:
        os_version = OSHelper.get_os().value
    paths = []

    current_locale = Settings.locale
    platform_directory = os.path.join(module_directory, "images", os_version)

    if current_locale != "":
        platform_locale_directory = os.path.join(platform_directory,
                                                 current_locale)
        for name in names:
            paths.append(os.path.join(platform_locale_directory, name))

    common_directory = os.path.join(module_directory, "images", "common")

    if current_locale != "":
        common_locale_directory = os.path.join(common_directory,
                                               current_locale)
        for name in names:
            paths.append(os.path.join(common_locale_directory, name))

    for name in names:
        paths.append(os.path.join(platform_directory, name))

    for name in names:
        paths.append(os.path.join(common_directory, name))

    found = False
    image_path = None
    for path in paths:
        if os.path.exists(path):
            found = True
            image_path = path
            break

    logger.debug("Module %s requests image %s" % (module, image))
    if found:
        logger.debug("Found %s" % image_path)
        return image_path
    else:
        raise APIHelperError("Image not found")