def open_about_firefox(): """Open the 'About Firefox' window.""" if OSHelper.get_os() == OSPlatform.MAC: type(Key.F3, modifier=KeyModifier.CTRL) type(Key.F2, modifier=KeyModifier.CTRL) time.sleep(0.5) type(Key.RIGHT) type(Key.DOWN) type(Key.DOWN) type(Key.ENTER) elif OSHelper.get_os() == OSPlatform.WINDOWS: type(Key.ALT) if args.locale != 'ar': type(Key.LEFT) else: type(Key.RIGHT) type(Key.ENTER) type(Key.UP) type(Key.ENTER) else: type(Key.F10) if args.locale != 'ar': type(Key.LEFT) else: type(Key.RIGHT) type(Key.UP) type(Key.ENTER)
def is_blocked(bug_id): """Checks if a Github issue/Bugzilla bug is blocked or not.""" try: if 'issue_' in bug_id: bug = get_github_issue(bug_id) if bug is None: return True if bug.state == 'closed': return False else: if OSHelper.get_os() in bug.title: return True return False else: bug = get_bugzilla_bug(bug_id) if bug is None: return True if bug.status in ['CLOSED', 'RESOLVED']: return False else: if bugzilla_os[OSHelper.get_os(). value] == bug.op_sys or bug.platform in [ 'All', 'Unspecified' ]: return True return False except BugManagerError as e: logger.error(str(e)) return True
def get_local_firefox_path() -> str or None: """Checks if Firefox is installed on your machine.""" paths = { 'osx': [ '/Applications/Firefox.app/Contents/MacOS/firefox', '/Applications/Firefox Developer Edition.app/Contents/MacOS/firefox', '/Applications/Firefox Nightly.app/Contents/MacOS/firefox' ], 'win': [ 'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe', 'C:\\Program Files (x86)\\Firefox Developer Edition\\firefox.exe', 'C:\\Program Files (x86)\\Nightly\\firefox.exe', 'C:\\Program Files\\Mozilla Firefox\\firefox.exe', 'C:\\Program Files\\Firefox Developer Edition\\firefox.exe', 'C:\\Program Files\\Nightly\\firefox.exe' ], 'linux': ['/usr/bin/firefox', '/usr/lib/firefox/firefox'] } if OSHelper.is_windows(): paths['win'].append(PathManager.get_win_environment_path()) for path in paths[OSHelper.get_os().value]: if os.path.exists(path): return path return None
def __init__(self, app, total_tests_run, passed_tests, failed_tests, skipped_tests, errors, total_time, failures): self.platform = OSHelper.get_os().value self.app = app self.total_tests_run = total_tests_run self.failed_tests = failed_tests self.passed_tests = passed_tests self.skipped_tests = skipped_tests self.error_tests = errors self.total_duration = total_time self.failures = failures
def generate_test_plan_name(firefox_version: str): """ :param firefox_version: actual version of Firefox :return: name of the test plan name of the test run is generated based on the OS , date and build number this method can be be improved to add more details """ test_plan_name = '[Firefox %s][%s]Iris Test Run %s' % ( firefox_version, OSHelper.get_os().capitalize(), date.today()) logger.debug('Creating Test Plan', test_plan_name) return test_plan_name
def select_location_bar_option(option_number): """Select option from the location bar menu. :param option_number: Option number. :return: None. """ if OSHelper.get_os() == OSPlatform.WINDOWS: for i in range(option_number + 1): type(Key.DOWN) type(Key.ENTER) else: for i in range(option_number - 1): type(Key.DOWN) type(Key.ENTER)
def get_rule_for_channel(channel, current_version): """ :param channel: Firefox channel. :param current_version: Current Firefox version. :return: Channel's list of rules. """ rules = get_update_rules() if rules is None: return None result_list = [ x for x in rules if x['channel'] == channel and OSHelper.get_os() in x['os'] and check_version(current_version, x['starting_condition']) ] if len(result_list) == 0: return None elif len(result_list) > 1: logger.warning('Multiple rules for \'{}\' channel'.format(channel)) return result_list[0] return result_list[0]
class Organize(object): NEW_BOOKMARK = Pattern('newbookmark.png') NEW_FOLDER = Pattern('newfolder.png') NEW_SEPARATOR = Pattern('newseparator.png') if OSHelper.get_os() != OSPlatform.MAC: CLOSE = Pattern('orgClose.png')
def pytest_runtest_setup(self, item): BaseTarget.pytest_runtest_setup(self, item) if OSHelper.is_mac(): mouse_reset() if item.name == 'run' and not core_args.override: skip_reason_list = [] values = item.own_markers[0].kwargs is_disabled = 'enabled' in values and not values.get( 'enabled') and not core_args.override is_excluded = 'exclude' in values and OSHelper.get_os( ) in values.get('exclude') incorrect_locale = 'locale' in values and core_args.locale not in values.get( 'locale') incorrect_platform = 'platform' in values and OSHelper.get_os( ) not in values.get('platform') fx_version = self.values.get('fx_version') incorrect_fx_version = 'fx_version' in values and not check_version( fx_version, values.get('fx_version')) if is_disabled: skip_reason_list.append('Test is disabled') if is_excluded: skip_reason_list.append('Test is excluded for {}'.format( OSHelper.get_os())) if 'blocked_by' in values: bug_id = '' platform = OSHelper.get_os() if type(values.get('blocked_by')) is str: bug_id = values.get('blocked_by') elif type(values.get('blocked_by')) is dict: try: bug_id = values.get('blocked_by')['id'] platform = values.get('blocked_by')['platform'] except KeyError as e: logger.debug('Missing key in blocked_by field: %s' % e) logger.debug('Looking up bug #%s...' % bug_id) blocked_platform = OSHelper.get_os() in platform logger.debug('Test has blocking issue: %s' % is_blocked(bug_id)) logger.debug('Test is blocked on this platform: %s' % blocked_platform) if is_blocked(bug_id) and blocked_platform: skip_reason_list.append( 'Test is blocked by [{}] on this platform.'.format( bug_id)) if incorrect_locale: skip_reason_list.append( 'Test doesn\'t support locale [{}]'.format( core_args.locale)) if incorrect_platform: skip_reason_list.append( 'Test doesn\'t support platform [{}]'.format( OSHelper.get_os())) if incorrect_fx_version: skip_reason_list.append( 'Test doesn\'t support Firefox version [{}]'.format( fx_version)) if len(skip_reason_list) > 0: logger.info('Test skipped: - [{}]: {} Reason(s): {}'.format( item.nodeid.split(':')[0], values.get('description'), ', '.join(skip_reason_list))) test_instance = (item, 'SKIPPED', None) test_result = create_result_object(test_instance, 0, 0) self.completed_tests.append(test_result) Target.index += 1 pytest.skip(item)
def get_images_path(): """Returns images directory path.""" return os.path.join('images', OSHelper.get_os().value)
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')