Example #1
0
def get_pref_value(pref_name):
    """Returns the value of a provided preference from 'about:config' page.

    :param pref_name: Preference's name.
    :return: Preference's value.
    """

    new_tab()
    select_location_bar()
    paste("about:config")
    type(Key.ENTER)
    time.sleep(Settings.DEFAULT_UI_DELAY)

    type(Key.SPACE)
    time.sleep(Settings.DEFAULT_UI_DELAY)

    paste(pref_name)
    time.sleep(Settings.DEFAULT_UI_DELAY_LONG)
    type(Key.TAB)
    time.sleep(Settings.DEFAULT_UI_DELAY_LONG)

    try:
        value = copy_to_clipboard().split("\t")[1]
    except Exception as e:
        raise APIHelperError(
            "Failed to retrieve preference value.\n{}".format(e))

    close_tab()
    return value
Example #2
0
def check_preference(pref_name, value):
    """Check the value for a specific preference.

    :param pref_name: Preference to be searched.
    :param value: Preference's value to be checked.
    :return: None.
    """

    new_tab()
    select_location_bar()

    paste("about:config")
    time.sleep(Settings.DEFAULT_UI_DELAY)
    type(Key.ENTER)
    time.sleep(Settings.DEFAULT_UI_DELAY)

    type(Key.SPACE)
    time.sleep(Settings.DEFAULT_UI_DELAY)

    paste(pref_name)

    time.sleep(Settings.DEFAULT_UI_DELAY_LONG)
    type(Key.TAB)
    time.sleep(Settings.DEFAULT_UI_DELAY_LONG)

    try:
        retrieved_value = copy_to_clipboard().split(";"[0])[1]

    except Exception as e:
        raise APIHelperError("Failed to retrieve preference value. %s" % e.message)

    if retrieved_value == value:
        return True
    else:
        return False
Example #3
0
def create_region_for_url_bar():
    """Create region for the right side of the url bar."""

    try:
        hamburger_menu_pattern = NavBar.HAMBURGER_MENU
        show_history_pattern = LocationBar.HISTORY_DROPMARKER
        select_location_bar()
        return RegionUtils.create_region_from_patterns(show_history_pattern, hamburger_menu_pattern, padding_top=20,
                                                       padding_bottom=20)
    except FindError:
        raise APIHelperError('Could not create region for URL bar.')
Example #4
0
def navigate(url):
    """Navigates, via the location bar, to a given URL.

    :param url: The string to type into the location bar.
    :return: None.
    """
    try:
        select_location_bar()
        paste(url)
        type(Key.ENTER)
    except Exception:
        raise APIHelperError(
            'No active window found, cannot navigate to page.')
Example #5
0
def navigate(url):
    """Navigates, via the location bar, to a given URL.

    :param url: The string to type into the location bar.
    :return: None.
    """
    try:
        select_location_bar()
        paste(url)
        time.sleep(Settings.DEFAULT_UI_DELAY_SHORT)
        type(Key.ENTER)
    except Exception:
        raise APIHelperError("No active window found, cannot navigate to page.")
Example #6
0
def get_support_info():
    """Returns support information as a JSON object from 'about:support' page."""
    copy_raw_data_to_clipboard = Pattern('about_support_copy_raw_data_button.png')

    new_tab()
    select_location_bar()
    paste('about:support')
    type(Key.ENTER)
    time.sleep(Settings.DEFAULT_UI_DELAY)

    try:
        click(copy_raw_data_to_clipboard)
        time.sleep(Settings.DEFAULT_UI_DELAY_LONG)
        json_text = get_clipboard()
        return json.loads(json_text)
    except Exception as e:
        raise APIHelperError('Failed to retrieve support information value.\n{}'.format(e))
    finally:
        close_tab()