def __init__(self, driver, browser_profile=None, proxy=None, keep_alive=False, file_detector=None, options=None): command_executor = driver.command_executor self.__driver = driver self.w3c = False self.__listeners = [] self.__listeners.append(PAFWebDriverListener()) RemoteWebDriver.__init__( self, command_executor=command_executor, desired_capabilities=driver.desired_capabilities, browser_profile=browser_profile, proxy=proxy, keep_alive=keep_alive, file_detector=file_detector, options=options) if ConfigurationsManager().contains_key( ApplicationProperties.WEBDRIVER_COMMAND_LISTENERS): class_name = ConfigurationsManager().get_str_for_key( ApplicationProperties.WEBDRIVER_COMMAND_LISTENERS) self.__listeners.append(load_class(class_name)())
def setAfterLamdaCap(context): print("setAfterLamdaCap method called : ") ConfigurationsManager().set_object_for_key( ApplicationProperties.REMOTE_SERVER, 'http://localhost:') ConfigurationsManager().set_object_for_key( ApplicationProperties.DRIVER_NAME, 'chromeDriver') BaseDriver().stop_driver()
def set_up(self): """ Load Application Properties Returns: None """ if os.path.exists('resources/application.properties'): self.__load_properties_file(self, 'resources/application.properties') # config = ConfigParser(interpolation=ExtendedInterpolation()) # config.read('application.properties') # for each_section in config.sections(): # for each_key, each_val in config.items(each_section): # ConfigurationsManager().set_object_for_key(value=each_val, key=each_key) if ResourcesManager.defaultLanguage is None and ConfigurationsManager( ).get_str_for_key('env.default.locale') is not None: ResourcesManager.defaultLanguage = str( ConfigurationsManager().get_str_for_key( 'env.default.locale')) envResources = str( ConfigurationsManager().get_str_for_key('env.resources')) commaSeparatedValues = envResources.split(';') self.__load_resources(commaSeparatedValues)
def __start_lambda_webdriver(self): remote_url = ConfigurationsManager().get_str_for_key( ApplicationProperties.REMOTE_SERVER) driver_capabilities = ConfigurationsManager().get_str_for_key( 'lambda.additional.capabilities') print("lambda capabilities : ") print(json.loads(driver_capabilities)) driver = webdriver.Remote( command_executor=remote_url, desired_capabilities=json.loads(driver_capabilities)) BaseDriver.__driver = pafwebdriver.PAFWebDriver(driver)
def setbeforeLambdaCap(context, index): print("setbeforeLambdaCap method called : ") BaseDriver().stop_driver() capObj = json.loads(index) capNew = (json.dumps(capObj['cap'])).replace("'", "\"") ConfigurationsManager().set_object_for_key( ApplicationProperties.DRIVER_NAME, 'lambdaTest') ConfigurationsManager().set_object_for_key( ApplicationProperties.REMOTE_SERVER, capObj['remote.server']) ConfigurationsManager().set_object_for_key( 'lambda.additional.capabilities', capNew)
def __start_appium_webdriver(self): driver_capabilities = ConfigurationsManager().get_dict_for_key( 'appium.additional.capabilities') selenium_server = ConfigurationsManager().get_str_for_key( ApplicationProperties.REMOTE_SERVER) selenium_port = ConfigurationsManager().get_str_for_key( ApplicationProperties.REMOTE_PORT) driver_capabilities["browserName"] = "" driver = appium_webdriver.Remote( selenium_server + selenium_port + "/wd/hub", driver_capabilities) BaseDriver.__driver = pafwebdriver.PAFAppiumWebDriver(driver) BaseDriver.__driver.implicitly_wait( ConfigurationsManager().get_str_for_key( ApplicationProperties.SELENIUM_WAIT_TIMEOUT))
def dragSourceOnValue(context, source, targetValue): value = ConfigurationsManager().get_str_for_key(source, default_value=source) getLocator = json.loads(value)['locator'] text = "arguments[0].setAttribute('value'," + targetValue + ");if(typeof(arguments[0].onchange) === 'function'){arguments[0].onchange('');}" BaseDriver().get_driver().execute_script( text, Find_PAFWebElement(typeBy(getLocator), locator(getLocator)))
def wait_for_ajax(self, jstoolkit=js_toolkit.GLOBAL_WAIT_CONDITION, wait_time=0): wait_time_out = ConfigurationsManager().get_int_for_key(ApplicationProperties.SELENIUM_WAIT_TIMEOUT) \ if wait_time == 0 else wait_time message = 'Wait time out for ajax to complete' return WebDriverWait(base_driver.BaseDriver().get_driver(), wait_time_out).until( WaitForAjax(jstoolkit), message )
def start_driver(self): """ Start web driver session by referring driver capabilities for AUT. Returns: None """ if BaseDriver.__driver is not None: self.stop_driver() default_browser = ConfigurationsManager().get_str_for_key( ApplicationProperties.DRIVER_NAME) if 'appium' in default_browser.lower(): self.__start_appium_webdriver() else: self.__start_webdriver()
def wait_for_visible(self, wait_time=0): wait_time_out = ConfigurationsManager().get_int_for_key(ApplicationProperties.SELENIUM_WAIT_TIMEOUT) \ if wait_time == 0 else wait_time message = 'Wait time out for ' + self.description + ' to be visible' return WebDriverWait(base_driver.BaseDriver().get_driver(), wait_time_out).until( WaitForVisible((self.by, self.locator)), message)
def __init__(self, key, cacheable=False): self.locator = None self.by = None self.description = None self._parent_element = None self._listeners = [] self.cacheable = cacheable if isinstance(key, str) and len(key) > 0: value = ConfigurationsManager().get_str_for_key(key, default_value=key) #print("30"+value+" loading") try: locator = json.loads(value)['locator'] # self.description = json.loads(value)['description'] except ValueError: locator = value # self.description = value parent = base_driver.BaseDriver().get_driver() self.by, self.locator = get_find_by(locator) if parent.w3c and parent._is_remote is False: if self.by == By.ID: self.by = By.CSS_SELECTOR self.locator = '[id="%s"]' % self.locator elif self.by == By.TAG_NAME: self.by = By.CSS_SELECTOR elif self.by == By.CLASS_NAME: self.by = By.CSS_SELECTOR self.locator = ".%s" % self.locator elif self.by == By.NAME: self.by = By.CSS_SELECTOR self.locator = '[name="%s"]' % self.locator self.description = self.locator self.cacheable = cacheable self._id = -1 RemoteWebElement.__init__(self, parent=parent, id_=self.id, w3c=parent.w3c) if ConfigurationsManager().contains_key( ApplicationProperties.WEBELEMENT_COMMAND_LISTENERS): class_name = ConfigurationsManager().get_str_for_key( ApplicationProperties.WEBELEMENT_COMMAND_LISTENERS) self._listeners.append(load_class(class_name)())
def wait_for_not_selected(self, wait_time=0): wait_time_out = ConfigurationsManager().get_int_for_key(ApplicationProperties.SELENIUM_WAIT_TIMEOUT) \ if wait_time == 0 else wait_time message = "Wait time out for " + self.description + " not to be selected" return WebDriverWait(base_driver.BaseDriver().get_driver(), wait_time_out).until( WaitForNotSelected((self.by, self.locator)), message)
def wait_for_not_containing_text(self, text_, wait_time=0): wait_time_out = ConfigurationsManager().get_int_for_key(ApplicationProperties.SELENIUM_WAIT_TIMEOUT) \ if wait_time == 0 else wait_time message = "Wait time out for " + self.description + " containing text not " + text_ return WebDriverWait(base_driver.BaseDriver().get_driver(), wait_time_out).until( WaitForNotContainingText( (self.by, self.locator), text_), message)
def wait_for_not_attribute(self, attr_, value_, wait_time=0): wait_time_out = ConfigurationsManager().get_int_for_key(ApplicationProperties.SELENIUM_WAIT_TIMEOUT) \ if wait_time == 0 else wait_time message = "Wait time out for " + self.description + " " + attr_ + " != " + value_ return WebDriverWait(base_driver.BaseDriver().get_driver(), wait_time_out).until( WaitForNotAttribute((self.by, self.locator), attr_, value_), message)
def after_all(context): base_environment.after_all(context) is_integration_enabled = ConfigurationsManager().get_str_for_key( "automation.qmetry.enabled", "false") if str(is_integration_enabled).lower() == "true" or str( is_integration_enabled).lower() == "yes": upload_result = UploadResult() upload_result.uploadFile()
def wait_for_css_style(self, style_name_, value_, wait_time=0): wait_time_out = ConfigurationsManager().get_int_for_key(ApplicationProperties.SELENIUM_WAIT_TIMEOUT) \ if wait_time == 0 else wait_time message = "Wait time out for " + self.description + " have css style " + style_name_ + "=" + value_ return WebDriverWait(base_driver.BaseDriver().get_driver(), wait_time_out).until( WaitForCssStyle((self.by, self.locator), style_name_, value_), message)
def wait_for_not_css_class(self, class_name_, wait_time=0): wait_time_out = ConfigurationsManager().get_int_for_key(ApplicationProperties.SELENIUM_WAIT_TIMEOUT) \ if wait_time == 0 else wait_time message = "Wait time out for " + self.description + " have not css class " + class_name_ return WebDriverWait(base_driver.BaseDriver().get_driver(), wait_time_out).until( WaitForNotCssClass((self.by, self.locator), class_name_), message)
def offsetDragAndDropPerform(context, source, xtarget, ytarget): value = ConfigurationsManager().get_str_for_key(source, default_value=source) getLocator = json.loads(value)['locator'] # ActionChains(BaseDriver().get_driver()).drag_and_drop_by_offset(Find_PAFWebElement(typeBy(getLocator),locator(getLocator)),int(xtarget),int(ytarget)).perform() ActionChains(BaseDriver().get_driver()).click_and_hold( Find_PAFWebElement(typeBy(getLocator), locator(getLocator))).move_by_offset( int(xtarget), int(ytarget)).release().perform()
def report(operation, outcome, msg, **kwargs): key = "element." + operation + "." + ("pass" if outcome else "fail") message_format = ConfigurationsManager().get_str_for_key(key) not_op_pass_format = "Expected {expected} not {operation} : " \ "Actual {actual} not {operation}" not_op_fail_format = "Expected {expected} not {operation} : " \ "Actual {actual} {operation}" op_pass_format = "Expected {expected} {operation} : " \ "Actual {actual} {operation}" op_fail_format = "Expected {expected} {operation} : " \ "Actual {actual} not {operation}" not_op_val_format = "Expected %(op)s {operation} should not be {expected} : " \ "Actual %(op)s {operation} is {actual}" op_val_format = "Expected %(op)s {operation} should be {expected} : " \ "Actual %(op)s {operation} is {actual}" if message_format is None: condition_1 = not_op_val_format if ( kwargs is not None and len(kwargs) > 2) else ( not_op_pass_format if outcome else not_op_fail_format) condition_2 = op_val_format if ( kwargs is not None and len(kwargs) > 2) else ( op_pass_format if outcome else op_fail_format) message_format = condition_1 if operation.startswith( 'not') else condition_2 message_format = message_format.replace( '{operation}', operation.replace('not', '')) message = message_format.format(expected=msg, actual=msg) if kwargs is not None and len(kwargs.keys()) > 0: message = message % kwargs else: message = message % {"expected": msg, "actual": msg} if outcome: Reporter.log(message, MessageType.Pass) else: Reporter.log(message, MessageType.Fail)
def dragAndDropPerform(context, source, target): value = ConfigurationsManager().get_str_for_key(source, default_value=source) getLocator = json.loads(value)['locator'] BaseDriver().get_driver().execute_script( jsText() + "simulateDragDrop(arguments[0], arguments[1])", Find_PAFWebElement(typeBy(getLocator), locator(getLocator)), Find_PAFWebElement(typeBy(target), locator(target))) # ActionChains(BaseDriver().get_driver()).drag_and_drop(Find_PAFWebElement(typeBy(getLocator),locator(getLocator)), Find_PAFWebElement(typeBy(target),locator(target))).perform() ActionChains(BaseDriver().get_driver()).click_and_hold( Find_PAFWebElement(typeBy(getLocator), locator(getLocator))).release( Find_PAFWebElement(typeBy(target), locator(target))).perform()
def find_element(self, by=By.ID, value=None, key=None): if key is not None and len(key) > 0: value = ConfigurationsManager().get_str_for_key(key, default_value=key) by, value = get_find_by(value) web_element = super(PAFWebDriver, self).find_element( by=by, value=value) paf_web_element = pafwebelement.PAFWebElement.create_instance_using_webelement( web_element) paf_web_element._parent = self paf_web_element.by = by paf_web_element.locator = value paf_web_element.description = value return paf_web_element
def __start_webdriver(self): driver_name = ConfigurationsManager().get_str_for_key( ApplicationProperties.DRIVER_NAME) driver_name = str(driver_name).lower() driver_capabilities = ConfigurationsManager().get_str_for_key( driver_name[:driver_name.index('driver')] + '.additional.capabilities') if driver_capabilities is not None and 'driverClass' in driver_capabilities: class_name = driver_capabilities['driverClass'] else: class_name = 'selenium.webdriver.{driver_name}.webdriver.WebDriver'. \ format(driver_name=driver_name[:driver_name.index('driver')]) #print("driver class" + class_name) selenium_server = ConfigurationsManager().get_str_for_key( ApplicationProperties.REMOTE_SERVER) selenium_port = ConfigurationsManager().get_str_for_key( ApplicationProperties.REMOTE_PORT) command_executor = selenium_server + selenium_port + "/wd/hub" if driver_capabilities is None: driver_class = load_class(class_name)() elif "remote" in ConfigurationsManager().get_str_for_key( ApplicationProperties.DRIVER_NAME).lower(): driver_class = load_class(class_name)( command_executor=command_executor, desired_capabilities=json.loads(driver_capabilities)) else: driver_class = load_class(class_name)( desired_capabilities=json.loads(driver_capabilities)) env_base_url = ConfigurationsManager().get_str_for_key( ApplicationProperties.SELENIUM_BASE_URL) BaseDriver.__driver = pafwebdriver.PAFWebDriver(driver_class) BaseDriver.__driver.get(env_base_url) BaseDriver.__driver.implicitly_wait( ConfigurationsManager().get_str_for_key( ApplicationProperties.SELENIUM_WAIT_TIMEOUT))
def __load_plist_file(file_path): """ This method will load key-value pairs store in plist file and stores them in configuration manager. Args: file_path(str): Path of plist file. Returns: None """ with open(file_path, 'rb') as fp: _dict = plistlib.load(fp) for key, value in _dict.items(): ConfigurationsManager().set_object_for_key(value=value, key=key)
def __load_properties_file(self, file_path): """ This method will load key-value pairs store in plist file and stores them in configuration manager. Args: file_path(str): Path of plist file. Returns: None """ #print("inside __load_properties_file()") _dict = self.load_properties(file_path, "=", "#") for key, value in _dict.items(): ConfigurationsManager().set_object_for_key(value=value, key=key)
def __load_ini_file(file_path): """ This method will load key-value pairs store in ini file and stores them in configuration manager. Args: file_path(str): Path of ini file. Returns: None """ config = ConfigParser(interpolation=ExtendedInterpolation()) config.read(file_path) for each_section in config.sections(): for key, value in config.items(each_section): ConfigurationsManager().set_object_for_key(key=key, value=value)
def loadQTM4JServerParams(self, params): params['format'] = "qas/json" if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.aliasName")) != ""): params['aliasName'] = ConfigurationsManager().get_str_for_key( "automation.qmetry.aliasName") if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.testrunname")) != ""): params['testRunName'] = ConfigurationsManager().get_str_for_key( "automation.qmetry.testrunname") if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.labels")) != ""): params['labels'] = ConfigurationsManager().get_str_for_key( "automation.qmetry.labels") if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.components")) != ""): params['components'] = ConfigurationsManager().get_str_for_key( "automation.qmetry.components") if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.version")) != ""): params['versions'] = ConfigurationsManager().get_str_for_key( "automation.qmetry.version") if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.sprint")) != ""): params['sprint'] = ConfigurationsManager().get_str_for_key( "automation.qmetry.sprint") if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.platform")) != ""): params['platform'] = ConfigurationsManager().get_str_for_key( "automation.qmetry.platform") if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.testrunkey")) != ""): params['testRunKey'] = ConfigurationsManager().get_str_for_key( "automation.qmetry.testrunkey") if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.comment")) != ""): params['comment'] = ConfigurationsManager().get_str_for_key( "automation.qmetry.comment") if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.testassethierarchy")) != ""): params['testAssetHierarchy'] = ConfigurationsManager( ).get_str_for_key("automation.qmetry.testassethierarchy") print(" params1 : ") print(params)
def uploadFile(self): self.createZipOfResultDir() isOnPremise = str(ConfigurationsManager().get_str_for_key( "automation.qmetry.onpremise")) integrationType = ConfigurationsManager().get_str_for_key( "automation.qmetry.type") apiKey = ConfigurationsManager().get_str_for_key( "automation.qmetry.apikey") url = ConfigurationsManager().get_str_for_key("automation.qmetry.url") headers = {} file = open('report.zip', 'rb') files = {'file': file} params = {} if (integrationType == 'QTM'): headers['apiKey'] = apiKey headers['scope'] = 'default' headers['accept'] = 'application/json' params['testCaseUpdateLevel'] = 1 params['entityType'] = "QAF" self.loadQTMParams(params) print(str(params)) res = requests.request("post", url, data=params, headers=headers, files=files) print(res) print(res.content) elif (isOnPremise == "true" and integrationType == "QTM4J"): print("QTM4J Server") username = ConfigurationsManager().get_str_for_key( "automation.qmetry.username") password = ConfigurationsManager().get_str_for_key( "automation.qmetry.password") s = username + ":" + password data_bytes = s.encode("utf-8") encodedAuth = base64.b64encode(data_bytes).decode('utf-8') print(encodedAuth) headers['Authorization'] = "Basic " + str(encodedAuth) params['apiKey'] = apiKey # print(headers) self.loadQTM4JServerParams(params) res = requests.request("post", url, data=params, headers=headers, files=files) print(res) print(res.content) elif (isOnPremise == "false" and integrationType == "QTM4J4x"): print("QTM4J4x CLoud") headers['Content-Type'] = "application/json" headers['apiKey'] = apiKey params['isZip'] = 'true' self.loadQTM4J4xCloudParams(params) res = requests.request("post", url, data=json.dumps(params), headers=headers) res = json.loads(res.text) requestUrl = res['url'] trackingId = res['trackingId'] headers = {} params = {} headers['Content-Type'] = "multipart/form-data" res1 = requests.request("put", requestUrl, data=params, headers=headers, files=files) schedule.every(2).seconds.do(self.getQTM4J4xUrl, id=trackingId, apiKey=apiKey) while 1: schedule.run_pending() time.sleep(1) print(res1) elif (isOnPremise == "true" and integrationType == "QTM4J4x"): print("QTM4J4x SERVER") username = ConfigurationsManager().get_str_for_key( "automation.qmetry.username") password = ConfigurationsManager().get_str_for_key( "automation.qmetry.password") s = username + ":" + password data_bytes = s.encode("utf-8") encodedAuth = base64.b64encode(data_bytes).decode('utf-8') print(encodedAuth) headers['Authorization'] = "Basic " + str(encodedAuth) headers['Content-Type'] = "application/json" headers['apiKey'] = apiKey params['isZip'] = 'true' self.loadQTM4J4xCloudParams(params) res = requests.request("post", url, data=json.dumps(params), headers=headers) res = json.loads(res.text) requestUrl = res['url'] trackingId = res['trackingId'] print(res) headers = {} params = {} headers['apiKey'] = apiKey headers['Authorization'] = "Basic " + str(encodedAuth) res1 = requests.request("POST", requestUrl, data=params, headers=headers, files=files) schedule.every(2).seconds.do( self.getQTM4J4xServerUrl, url=url.strip('/rest/qtm4j/automation/latest/importresult'), Authorization="Basic " + str(encodedAuth), id=trackingId, apiKey=apiKey) while 1: schedule.run_pending() time.sleep(1) print(res1) else: print("QTM4J CLoud") headers['Content-Type'] = "application/json" params['apiKey'] = apiKey params['testCaseUpdateLevel'] = 1 params['isZip'] = 'true' self.loadQTM4JCloudParams(params) res = requests.request("post", url, data=json.dumps(params), headers=headers) res = json.loads(res.text) requestUrl = res['url'] trackingId = res['trackingId'] headers = {} params = {} headers['Content-Type'] = "multipart/form-data" res1 = requests.request("put", requestUrl, data=params, headers=headers, files=files) schedule.every(2).seconds.do(self.getQTM4JUrl, id=trackingId) while 1: schedule.run_pending() time.sleep(1) print(res1) file.close() isDebug = str( ConfigurationsManager().get_str_for_key("automation.qmetry.debug")) if isDebug == "true": print("debug is true, so do not remove zip file") else: print("debug is false, so remove zip file") os.remove("report.zip")
def loadQTMParams(self, params): if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.platformid")) != ""): params['cycleID'] = ConfigurationsManager().get_str_for_key( "automation.qmetry.cycleid") if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.platformid")) != ""): params['platformID'] = ConfigurationsManager().get_str_for_key( "automation.qmetry.platformid") if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.testsuiteid")) != ""): params['testsuiteId'] = ConfigurationsManager().get_str_for_key( "automation.qmetry.testsuiteid") if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.testsuitename")) != ""): params['testsuiteName'] = ConfigurationsManager().get_str_for_key( "automation.qmetry.testsuitename") if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.projectid")) != ""): params['projectID'] = ConfigurationsManager().get_str_for_key( "automation.qmetry.projectid") if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.releaseid")) != ""): params['releaseID'] = ConfigurationsManager().get_str_for_key( "automation.qmetry.releaseid") if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.buildid")) != ""): params['buildID'] = ConfigurationsManager().get_str_for_key( "automation.qmetry.buildid") if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.testsuiteFields")) != ""): params['testsuite_fields'] = ConfigurationsManager( ).get_str_for_key("automation.qmetry.testsuiteFields") if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.testcaseFields")) != ""): params['testcase_fields'] = ConfigurationsManager( ).get_str_for_key("automation.qmetry.testcaseFields") if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.automationhierarchy")) != ""): params['automationHierarchy'] = ConfigurationsManager( ).get_str_for_key("automation.qmetry.automationhierarchy") params['testcase_fields'] = params['testcase_fields'].replace( '"[', '[').replace(']"', ']') params['testsuite_fields'] = params['testsuite_fields'].replace( '"[', '[').replace(']"', ']') print(" params1 : ") print(params)
def loadQTM4J4xCloudParams(self, params): params['format'] = "qaf" if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.aliasName")) != ""): params['aliasName'] = ConfigurationsManager().get_str_for_key( "automation.qmetry.aliasName") if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.testCycleToReuse")) != ""): params['testCycleToReuse'] = ConfigurationsManager( ).get_str_for_key("automation.qmetry.testCycleToReuse") if ((ConfigurationsManager().get_str_for_key( "automation.qmetry.environment")) != ""): params['environment'] = ConfigurationsManager().get_str_for_key( "automation.qmetry.environment") if ((ConfigurationsManager().get_str_for_key("automation.qmetry.build") ) != ""): params['build'] = ConfigurationsManager().get_str_for_key( "automation.qmetry.build") fields = { 'testCycle': { 'labels': ConfigurationsManager().get_str_for_key( "automation.qmetry.testcycle.labels").split(',') if (ConfigurationsManager().get_str_for_key( "automation.qmetry.testcycle.labels")) != "" else [], 'components': ConfigurationsManager().get_str_for_key( "automation.qmetry.testcycle.components").split(',') if (ConfigurationsManager().get_str_for_key( "automation.qmetry.testcycle.components")) != "" else [], 'priority': ConfigurationsManager().get_str_for_key( "automation.qmetry.testcycle.priority") if (ConfigurationsManager().get_str_for_key( "automation.qmetry.testcycle.priority")) != "" else '', 'status': ConfigurationsManager().get_str_for_key( "automation.qmetry.testcycle.status") if (ConfigurationsManager().get_str_for_key( "automation.qmetry.testcycle.status")) != "" else '', 'sprintId': ConfigurationsManager().get_str_for_key( "automation.qmetry.testcycle.sprintId") if (ConfigurationsManager().get_str_for_key( "automation.qmetry.testcycle.sprintId")) != "" else '', 'fixVersionId': ConfigurationsManager().get_str_for_key( "automation.qmetry.testcycle.fixVersionId") if (ConfigurationsManager().get_str_for_key( "automation.qmetry.testcycle.fixVersionId")) != "" else '', 'summary': ConfigurationsManager().get_str_for_key( "automation.qmetry.testcycle.summary") if (ConfigurationsManager().get_str_for_key( "automation.qmetry.testcycle.summary")) != "" else 'Automated Test Cycle', 'description': ConfigurationsManager().get_str_for_key( "automation.qmetry.testcycle.description") if (ConfigurationsManager().get_str_for_key( "automation.qmetry.testcycle.description")) != "" else '', 'assignee': ConfigurationsManager().get_str_for_key( "automation.qmetry.testcycle.assignee") if (ConfigurationsManager().get_str_for_key( "automation.qmetry.testcycle.assignee")) != "" else '', 'customFields': (json.loads(ConfigurationsManager().get_str_for_key( "automation.qmetry.testcycle.customFields"))) if (ConfigurationsManager().get_str_for_key( "automation.qmetry.testcycle.customFields")) != "" else [] }, 'testCase': { 'labels': ConfigurationsManager().get_str_for_key( "automation.qmetry.testcase.labels").split(',') if (ConfigurationsManager().get_str_for_key( "automation.qmetry.testcase.labels")) != "" else [], 'components': ConfigurationsManager().get_str_for_key( "automation.qmetry.testcase.components").split(',') if (ConfigurationsManager().get_str_for_key( "automation.qmetry.testcase.components")) != "" else [], 'priority': ConfigurationsManager().get_str_for_key( "automation.qmetry.testcase.priority") if (ConfigurationsManager().get_str_for_key( "automation.qmetry.testcase.priority")) != "" else '', 'status': ConfigurationsManager().get_str_for_key( "automation.qmetry.testcase.status") if (ConfigurationsManager().get_str_for_key( "automation.qmetry.testcase.status")) != "" else '', 'sprintId': ConfigurationsManager().get_str_for_key( "automation.qmetry.testcase.sprintId") if (ConfigurationsManager().get_str_for_key( "automation.qmetry.testcase.sprintId")) != "" else '', 'fixVersionId': ConfigurationsManager().get_str_for_key( "automation.qmetry.testcase.fixVersionId") if (ConfigurationsManager().get_str_for_key( "automation.qmetry.testcase.fixVersionId")) != "" else '', 'description': ConfigurationsManager().get_str_for_key( "automation.qmetry.testcase.description") if (ConfigurationsManager().get_str_for_key( "automation.qmetry.testcase.description")) != "" else '', 'assignee': ConfigurationsManager().get_str_for_key( "automation.qmetry.testcase.assignee") if (ConfigurationsManager().get_str_for_key( "automation.qmetry.testcase.assignee")) != "" else '', 'customFields': (json.loads(ConfigurationsManager().get_str_for_key( "automation.qmetry.testcase.customFields"))) if (ConfigurationsManager().get_str_for_key( "automation.qmetry.testcase.customFields")) != "" else [] } } params['fields'] = fields print(" params1 : ") print(params)
def before_feature(self, context, feature): envInfoDetails = { "browser-desired-capabilities": {}, "browser-actual-capabilities": {}, "isfw-build-info": {}, "run-parameters": {}, "execution-env-info": {} } current_feature_directory = os.path.join( os.getenv('REPORT_DIR'), 'json', re.sub('[^A-Za-z0-9]+', ' - ', re.sub('.feature', '', feature.filename))) create_directory(current_feature_directory) os.environ['CURRENT_FEATURE_DIR'] = current_feature_directory ExecutionMetaInfo().add_test( re.sub('[^A-Za-z0-9]+', ' - ', re.sub('.feature', '', feature.filename))) FeatureOverView().startTime = current_timestamp() FeatureOverView().add_class(feature.name) # driver_name = str(ConfigurationsManager().get_str_for_key('driver.name')) # driver_name[:str(driver_name).lower().index('driver')] envInfoDetails["browser-desired-capabilities"][ "browserName"] = BaseDriver().get_driver( ).capabilities['browserName'] envInfoDetails["browser-desired-capabilities"][ "cssSelectorsEnabled"] = "true" envInfoDetails["browser-desired-capabilities"][ "javascriptEnabled"] = "true" envInfoDetails["browser-desired-capabilities"][ "takesScreenshot"] = "true" envInfoDetails["browser-desired-capabilities"]["platform"] = str( ConfigurationsManager().get_str_for_key('platform')) envInfoDetails["browser-desired-capabilities"]["version"] = BaseDriver( ).get_driver().capabilities['browserVersion'] json_object = BaseDriver().get_driver().capabilities pairs = json_object.items() for key, value in pairs: # print(str(value)) envInfoDetails["browser-actual-capabilities"][key] = str(value) envInfoDetails["isfw-build-info"]["qaf-Type"] = "core" envInfoDetails["isfw-build-info"][ "qaf-Build-Time"] = current_timestamp() envInfoDetails["isfw-build-info"]["qaf-Version"] = "3.0" envInfoDetails["run-parameters"]["resources"] = str( ConfigurationsManager().get_str_for_key('env.resources')) envInfoDetails["run-parameters"]["file.feature"] = "feature/" + str( ConfigurationsManager().get_str_for_key('platform')) envInfoDetails["run-parameters"]["baseurl"] = str( ConfigurationsManager().get_str_for_key('env.baseurl')) # envInfoDetails["execution-env-info"]["java.arch"] = "64" # envInfoDetails["execution-env-info"]["java.vendor"] = "Oracle Corporation 22" envInfoDetails["execution-env-info"][ "python.version"] = platform.python_version() envInfoDetails["execution-env-info"]["os.arch"] = platform.processor() envInfoDetails["execution-env-info"]["host"] = platform.node() envInfoDetails["execution-env-info"]["os.name"] = platform.platform() envInfoDetails["execution-env-info"]["user.name"] = os.getlogin() envInfoDetails["execution-env-info"]["os.version"] = platform.version() # drivercap = json.loads(BaseDriver.__driver.capabilities) # print(BaseDriver().get_driver().capabilities['browserName']) FeatureOverView().add_envInfo(envInfoDetails)