def test_chrome_facebook_load_homepage(self): start_time = time.time() self.round_status = self.sikuli.run_test(self.env.test_name, self.env.output_name, test_target=self.env.TEST_FB_HOME, script_dp=self.env.test_script_py_dp) end_time = time.time() elapsed_time = end_time - start_time logger = get_logger(os.path.basename(__file__), os.getenv("ENABLE_ADVANCE")) logger.debug("Action Time Elapsed: [%s]" % elapsed_time)
def test_firefox_facebook_load_homepage(self): start_time = time.time() self.round_status = self.sikuli.run_test(self.env.test_name, self.env.output_name, test_target=self.env.TEST_FB_HOME, script_dp=self.env.test_script_py_dp) end_time = time.time() elapsed_time = end_time - start_time logger = get_logger(os.path.basename(__file__), os.getenv("ENABLE_ADVANCE")) logger.debug("Action Time Elapsed: [%s]" % elapsed_time)
def __init__(self, **kwargs): self.exec_config = {} self.online_config = {} self.index_config = {} self.global_config = {} self.firefox_config = {} # load exec-config, firefox-config, index-config, online-config and global config to self object self.exec_config_fp = os.path.abspath(kwargs['exec_config']) self.firefox_config_fp = os.path.abspath(kwargs['firefox_config']) self.index_config_fp = os.path.abspath(kwargs['index_config']) self.online_config_fp = os.path.abspath(kwargs['online_config']) self.global_config_fp = os.path.abspath(kwargs['global_config']) for variable_name in kwargs.keys(): setattr(self, variable_name, load_json_file(kwargs[variable_name])) # init logger self.logger = get_logger(__file__, self.exec_config['advance']) self.logger.debug( '\n###############\n# Important #\n###############\n') for v_name in kwargs.keys(): self.logger.debug('Loading Settings from {}:\n{}\n'.format( v_name, json.dumps(getattr(self, v_name), indent=4))) # init values self.firefox_profile_creator = FirefoxProfileCreator() self.settings_prefs = self.firefox_config.get('prefs', {}) self.cookies_settings = self.firefox_config.get('cookies', {}) self.extensions_settings = self.firefox_config.get('extensions', {}) self.suite_result_dp = '' self._firefox_profile_path = self.firefox_profile_creator.get_firefox_profile( prefs=self.settings_prefs, cookies_settings=self.cookies_settings, extensions_settings=self.extensions_settings) self.default_result_fp = os.path.join( os.getcwd(), self.global_config['default-result-fn']) # check the video recording, raise exception if more than one recorders CommonUtil.is_video_recording(self.firefox_config)
import os import sys import time import psutil import shutil import tempfile import subprocess from lib.common.logConfig import get_logger from lib.common.pyDriveUtil import PyDriveUtil from lib.helper.desktopHelper import close_browser logger = get_logger(__name__) class ChromeProfileCreator(object): def __init__(self, chrome_profile_path='', launch_cmd=''): self.browser_type = "chrome" self.current_platform_name = sys.platform if launch_cmd: self.firefox_cmd = launch_cmd else: if self.current_platform_name == 'darwin': self.process_name = "Google Chrome" elif self.current_platform_name == "linux2": self.process_name = "Chrome" else: self.process_name = "chrome.exe" if self.current_platform_name == 'darwin': self.process_name = "Google Chrome" elif self.current_platform_name == "linux2": self.process_name = "Chrome"
import sys import platform from PIL import Image from lib.common.windowController import WindowObject from lib.common.logConfig import get_logger logger = get_logger(__name__) def get_terminal_location(browser_x, browser_y, browser_w, browser_h): """ Get the terminal location base on browser location. @param browser_x: the browser x base. @param browser_y: the browser y base. @param browser_w: the browser width. @param browser_h: the browser height. @return: the location of Termianl, {x, y, withd, height} """ platform_name = sys.platform platform_release = platform.release() base_width = int(browser_x + browser_w) base_height = int(browser_y + browser_h) height_offset = 0 terminal_width = base_width terminal_height = 60 if platform_name == 'linux2': logger.info('Get terminal window offset for Linux.') height_offset = 20 terminal_height = 60
def __init__(self, **kwargs): self.logger = get_logger(__file__, kwargs['advance']) for variable_name in kwargs.keys(): self.logger.debug("Set variable name: %s with value: %s" % (variable_name, kwargs[variable_name])) setattr(self, variable_name, kwargs[variable_name])
def __init__(self, **kwargs): # init variables self.exec_config = {} self.index_config = {} self.upload_config = {} self.global_config = {} self.firefox_config = {} self.chrome_config = {} # load exec-config, firefox-config, index-config, upload-config and global config to self object self.exec_config_fp = os.path.abspath(kwargs['exec_config']) self.index_config_fp = os.path.abspath(kwargs['index_config']) self.upload_config_fp = os.path.abspath(kwargs['upload_config']) self.global_config_fp = os.path.abspath(kwargs['global_config']) self.firefox_config_fp = os.path.abspath(kwargs['firefox_config']) self.chrome_config_fp = os.path.abspath(kwargs['chrome_config']) for variable_name in kwargs.keys(): setattr(self, variable_name, CommonUtil.load_json_file(kwargs[variable_name])) # init logger self.logger = get_logger(__file__, self.exec_config['advance']) self.logger.debug('\n###############\n# Important #\n###############\n') for v_name in kwargs.keys(): self.logger.debug( 'Loading Settings from {}:\n{}\n'.format(v_name, json.dumps(getattr(self, v_name), indent=4))) # validate all configs before overwrite platform depend setting, raise Exception if failed self.validate_configs() # overwrite platform dep setting in configs self.__dict__.update( HasalConfigUtil.overwrite_platform_dep_settings_into_configs(self, "firefox_config", self.firefox_config, ["firefox_config"], sys.platform, platform.release()).__dict__) self.__dict__.update( HasalConfigUtil.overwrite_platform_dep_settings_into_configs(self, "chrome_config", self.chrome_config, ["chrome_config"], sys.platform, platform.release()).__dict__) # init values self.suite_result_dp = '' self.default_result_fp = os.path.join(os.getcwd(), self.global_config['default-result-fn']) if self.firefox_config.get('enable_create_new_profile', False): self.firefox_profile_creator = FirefoxProfileCreator(launch_cmd=self.firefox_config.get('launch-browser-cmd-path')) settings_prefs = self.firefox_config.get('prefs', {}) cookies_settings = self.firefox_config.get('cookies', {}) profile_files_settings = self.firefox_config.get('profile_files', {}) extensions_settings = self.firefox_config.get('extensions', {}) self._firefox_profile_path = self.firefox_profile_creator.get_firefox_profile( prefs=settings_prefs, cookies_settings=cookies_settings, profile_files_settings=profile_files_settings, extensions_settings=extensions_settings) else: self._firefox_profile_path = "" # chrome config if self.chrome_config.get('enable_create_new_profile', False): self.chrome_profile_creator = ChromeProfileCreator(launch_cmd=self.firefox_config.get('launch-browser-cmd-path')) chrome_cookies_settings = self.chrome_config.get('cookies', {}) self._chrome_profile_path = self.chrome_profile_creator.get_chrome_profile(cookies_settings=chrome_cookies_settings) else: self._chrome_profile_path = "" # check the video recording, raise exception if more than one recorders CommonUtil.is_video_recording(self.firefox_config) # check the upload config revision, raise exception if upload config enabled without revision if self.upload_config.get("perfherder-revision", "") == "" and self.upload_config.get("enable", False): raise Exception("Your current upload config is enabled [%s], but revision is empty [%s], please make sure your config set correctly" % (self.upload_config.get("perfherder-revision", ""), self.upload_config.get("enable", False)))