コード例 #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)
コード例 #2
0
ファイル: keyboard_shortcuts.py プロジェクト: mwxfr/mattapi
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)
コード例 #3
0
ファイル: email_client.py プロジェクト: mwxfr/mattapi
 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
コード例 #4
0
ファイル: pattern.py プロジェクト: mwxfr/mattapi
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 the above fails, we will look up the file name in the list of project-wide images,
    and return whatever we find, with a warning message.
    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

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