python类getmoduleinfo()的实例源码

iosOptions.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def get_ios_version(UDID = ''):
    ''' Reads the device version '''

    sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
    CommonUtil.ExecLog(sModuleInfo, "Started", 0)

    try:
        output = get_device_info(UDID) # Get device info in list format
        tmp = ''
        version = ''
        for line in output:
            if 'productversion' in line.lower():
                tmp = line
        if ( tmp != ''):
            tmp = tmp.split(":")
            version = tmp[1].strip()

        if version == '':
            CommonUtil.ExecLog(sModuleInfo, "Could not read the iOS version from the device", 3)
            return 'failed'

        CommonUtil.ExecLog(sModuleInfo, "%s" % version, 0)
        return version
    except Exception:
        return CommonUtil.Exception_Handler(sys.exc_info())
iosOptions.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def get_product_name(UDID=''):
    ''' Reads the phone name '''

    sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
    CommonUtil.ExecLog(sModuleInfo, "Started", 0)

    try:
        output = get_device_info(UDID)  # Get device info in list format
        tmp = ''
        product_name = ''
        for line in output:
            if 'productname' in line.lower():
                tmp = line
        if (tmp != ''):
            tmp = tmp.split(":")
            product_name = tmp[1].strip()

        if product_name == '':
            CommonUtil.ExecLog(sModuleInfo, "Could not read the iOS product name the device", 3)
            return 'failed'

        CommonUtil.ExecLog(sModuleInfo, "%s" % product_name, 0)
        return product_name
    except Exception:
        return CommonUtil.Exception_Handler(sys.exc_info())
BuiltInFunctions.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def Get_Element_Step_Data(step_data):
    sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
    CommonUtil.ExecLog(sModuleInfo, "Function: Get Element Step Data", 1)
    try:
        element_step_data = []
        for each in step_data:
            if (each[1] == "action" or each[1] == "conditional action"):
                #CommonUtil.ExecLog(sModuleInfo, "Not a part of element step data", 2)
                continue
            else:
                element_step_data.append(each)

        return element_step_data

    except Exception:
        return CommonUtil.Exception_Handler(sys.exc_info())


# Handles actions for the sequential logic, based on the input from the mentioned function
BuiltInFunctions.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def Get_Response(step_data):
    sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
    CommonUtil.ExecLog(sModuleInfo, "Function: Get_Response", 1)
    try:
        fields_to_be_saved = ''
        for row in step_data:
            if row[1] == 'action':
                fields_to_be_saved = row[2]

        element_step_data = Get_Element_Step_Data(step_data)

        returned_step_data_list = Validate_Step_Data(element_step_data)

        if ((returned_step_data_list == []) or (returned_step_data_list == "failed")):
            return "failed"
        else:
            try:
                return_result = handle_rest_call(returned_step_data_list, fields_to_be_saved)
                return return_result
            except Exception:
                return CommonUtil.Exception_Handler(sys.exc_info())
    except Exception:
        return CommonUtil.Exception_Handler(sys.exc_info())
BuiltInFunctions.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def Step_Result(step_data):
    sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
    CommonUtil.ExecLog(sModuleInfo, "Function: Step_Result", 1)
    try:
        if ((1 < len(step_data) >= 5)):
            CommonUtil.ExecLog(sModuleInfo,"The information in the data-set(s) are incorrect. Please provide accurate data set(s) information.",3)
            result = "failed"
        else:
            step_result = step_data[0][2]
            if step_result == 'pass':
                result = "passed"
            elif step_result == 'skip':
                result = 'skipped'
            elif step_result == 'fail':
                result = "failed"

        return result
    except Exception:
        return CommonUtil.Exception_Handler(sys.exc_info())

# Performs a series of action or conditional logical action decisions based on user input
BuiltInFunctions.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def Open_Browser_Wrapper(step_data):
    ''' Temporary wrapper for open_browser() until that function can be updated to use only data_set '''

    sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
    try:
        global dependency
        # Get the dependency again in case it was missed
        if Shared_Resources.Test_Shared_Variables('dependency'): # Check if driver is already set in shared variables
            dependency = Shared_Resources.Get_Shared_Variables('dependency') # Retreive selenium driver

        cmd = step_data[0][2] # Expected "open" or "close" for current method. May contain other strings for old method of Field="open browser"
        if cmd.lower().strip() == 'close': # User issued close command
            try: selenium_driver.close()
            except: pass
            return 'passed'
        else: # User issued "open" command or used old method of "open browser"
            return Open_Browser(dependency)
    except Exception:
        ErrorMessage =  "failed to open browser"
        return CommonUtil.Exception_Handler(sys.exc_info(), None, ErrorMessage)
BuiltInFunctions.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def Enter_Text_In_Text_Box(step_data):
    try:
        sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
        Element = LocateElement.Get_Element(step_data,selenium_driver)
        if Element != "failed":
            for each in step_data:
                if each[1]=="action":
                    text_value=each[2]
                    break
                else:
                    continue
            Element.click()
            Element.clear()
            Element.send_keys(text_value)
            Element.click()
            CommonUtil.TakeScreenShot(sModuleInfo)
            CommonUtil.ExecLog(sModuleInfo, "Successfully set the value of to text to: %s"%text_value, 1)
            return "passed"
        else:
            CommonUtil.ExecLog(sModuleInfo, "Unable to locate your element with given data.", 3)
            return "failed"
    except Exception:
        errMsg = "Could not select/click your element."
        return CommonUtil.Exception_Handler(sys.exc_info(),None,errMsg)
BuiltInFunctions.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def Click_and_Hold_Element(step_data):
    try:
        sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
        Element = LocateElement.Get_Element(step_data,selenium_driver)
        if Element != "failed":
                try:
                    click_and_hold = ActionChains(selenium_driver).click_and_hold(Element)
                    click_and_hold.perform()
                    CommonUtil.TakeScreenShot(sModuleInfo)
                    CommonUtil.ExecLog(sModuleInfo, "Successfully clicked and held the element with given parameters and values", 1)
                    return "passed"
                except Exception:
                    element_attributes = Element.get_attribute('outerHTML')
                    CommonUtil.ExecLog(sModuleInfo, "Element Attributes: %s"%(element_attributes),3)
                    errMsg = "Could not click and hold your element."
                    return CommonUtil.Exception_Handler(sys.exc_info(),None,errMsg)
        else:
            CommonUtil.ExecLog(sModuleInfo, "Unable to locate your element with given data.", 3)
            return "failed"    
    except Exception:
        return CommonUtil.Exception_Handler(sys.exc_info())


#Method to right click on element; step data passed on by the user
BuiltInFunctions.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def Context_Click_Element(step_data):
    try:
        sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
        Element = LocateElement.Get_Element(step_data,selenium_driver)
        if Element != "failed":
                try:
                    context_click = ActionChains(selenium_driver).context_click(Element)
                    context_click.perform()
                    CommonUtil.TakeScreenShot(sModuleInfo)
                    CommonUtil.ExecLog(sModuleInfo, "Successfully right clicked the element with given parameters and values", 1)
                    return "passed"
                except Exception:
                    element_attributes = Element.get_attribute('outerHTML')
                    CommonUtil.ExecLog(sModuleInfo, "Element Attributes: %s"%(element_attributes),3)
                    errMsg = "Could not right click your element."
                    return CommonUtil.Exception_Handler(sys.exc_info(),None,errMsg)
        else:
            CommonUtil.ExecLog(sModuleInfo, "Unable to locate your element with given data.", 3)
            return "failed"  
    except Exception:
        return CommonUtil.Exception_Handler(sys.exc_info())

#Method to double click on element; step data passed on by the user
BuiltInFunctions.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def Double_Click_Element(step_data):
    try:
        sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
        Element = LocateElement.Get_Element(step_data,selenium_driver)
        if Element != "failed":
            try:
                double_click = ActionChains(selenium_driver).double_click(Element)
                double_click.perform()
                CommonUtil.TakeScreenShot(sModuleInfo)
                CommonUtil.ExecLog(sModuleInfo, "Successfully double clicked the element with given parameters and values", 1)
                return "passed"
            except Exception:
                element_attributes = Element.get_attribute('outerHTML')
                CommonUtil.ExecLog(sModuleInfo, "Element Attributes: %s"%(element_attributes),3)
                errMsg = "Could not double click your element."
                return CommonUtil.Exception_Handler(sys.exc_info(),None,errMsg)
        else:
            CommonUtil.ExecLog(sModuleInfo, "Unable to locate your element with given data.", 3)
            return "failed"      
    except Exception:
        return CommonUtil.Exception_Handler(sys.exc_info())


#Method to move to middle of the element; step data passed on by the user
BuiltInFunctions.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def Move_To_Element(step_data):
    try:
        sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
        Element = LocateElement.Get_Element(step_data,selenium_driver)
        if Element != "failed":
            try:
                move = ActionChains(selenium_driver).move_to_element(Element).perform()
                CommonUtil.TakeScreenShot(sModuleInfo)
                CommonUtil.ExecLog(sModuleInfo, "Successfully moved to the middle of the element with given parameters and values", 1)
                return "passed"
            except Exception:
                element_attributes = Element.get_attribute('outerHTML')
                CommonUtil.ExecLog(sModuleInfo, "Element Attributes: %s"%(element_attributes),3)
                errMsg = "Could not move to your element your element."
                return CommonUtil.Exception_Handler(sys.exc_info(),None,errMsg)
        else:
            CommonUtil.ExecLog(sModuleInfo, "Unable to locate your element with given data.", 3)
            return "failed"   
    except Exception:
        return CommonUtil.Exception_Handler(sys.exc_info())


#Method to hover over element; step data passed on by the user
BuiltInFunctions.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def Sleep(step_data):
    sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
    CommonUtil.ExecLog(sModuleInfo, "Function start", 0)
    try:
        if ((1 < len(step_data) >= 2)):
            CommonUtil.ExecLog(sModuleInfo,"Please provide single row of data for only sleep. Consider using wait instead",3)
            return "failed"
        else:
            tuple = step_data[0]
            seconds = int(tuple[2])
            CommonUtil.ExecLog(sModuleInfo,"Sleeping for %s seconds"%seconds,1)
            time.sleep(seconds)
            return "passed"
        #return result
    except Exception:
        return CommonUtil.Exception_Handler(sys.exc_info())


#Method to scroll down a page
BuiltInFunctions.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def Navigate(step_data):
    sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
    CommonUtil.ExecLog(sModuleInfo, "Function start", 0)
    try:
        if ((1 < len(step_data) >= 2)):
            CommonUtil.ExecLog(sModuleInfo,"Please provide only single row of data",3)
            return "failed"
        else:
            navigate = step_data[0][2]
            if navigate == 'back':
                selenium_driver.back()
                CommonUtil.ExecLog(sModuleInfo, "Performing browser back", 1)
            elif navigate == 'forward':
                selenium_driver.forward()
                CommonUtil.ExecLog(sModuleInfo, "Performing browser forward", 1)
            elif navigate == 'refresh':
                selenium_driver.refresh()
                CommonUtil.ExecLog(sModuleInfo, "Performing browser refresh", 1)
            else:
                CommonUtil.ExecLog(sModuleInfo, "Value invalid. Only 'back', 'forward', 'refresh' allowed", 3)
                return "failed"
            return "passed"
    except Exception:
        return CommonUtil.Exception_Handler(sys.exc_info())
common_functions.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def step_result(data_set):
    ''' Returns passed/failed in the standard format, when the user specifies it in the step data '''

    sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
    CommonUtil.ExecLog(sModuleInfo,"Function Start", 0)

    try:
        action_value = ''
        for row in data_set:
            if row[0] == 'step result' and row[1] == 'action':
                action_value = row[2]
    except:
        return CommonUtil.Exception_Handler(sys.exc_info())

    if action_value in failed_tag_list: # Convert user specified pass/fail into standard result
        return 'failed'
    elif action_value in skipped_tag_list:
        return 'skipped'
    elif action_value in passed_tag_list:
        return 'passed'
    else:
        CommonUtil.ExecLog(sModuleInfo, "Step Result action has invalid VALUE", 3)
        return 'failed'
common_functions.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def step_exit(data_set):
    ''' Exits a Test Step wtih passed/failed in the standard format, when the user specifies it in the step data '''

    sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
    CommonUtil.ExecLog(sModuleInfo,"Function Start", 0)

    try:
        action_value = ''
        for row in data_set:
            if row[0] == 'step exit' and row[1] == 'action':
                action_value = row[2]
    except:
        return CommonUtil.Exception_Handler(sys.exc_info())

    if action_value in failed_tag_list: # Convert user specified pass/fail into standard result
        return 'failed'
    elif action_value in skipped_tag_list:
        return 'skipped'
    elif action_value in passed_tag_list:
        return 'passed'
    else:
        CommonUtil.ExecLog(sModuleInfo, "Step Result action has invalid VALUE", 3)
        return 'failed'
common_functions.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def append_list_shared_variable(data_set):
    ''' Delete all shared variables - Wrapper for Clean_Up_Shared_Variables() '''
    # To delete only one, use the action "save variable", and set it to an empty string
    # Takes no inputs

    sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
    CommonUtil.ExecLog(sModuleInfo,"Function Start", 0)

    try:
        # Parse data set
        tmp = data_set[0][2].replace(' ', '').strip() # Get key and value from Value field and clean them
        shared_var = tmp.split('=')[0].strip() # Get variable name
        tmp = tmp.replace(shared_var, '').strip().replace('=', '', 1)
        values = tmp.split(',') # Get values (could be several)

        # Append all values
        for value in values:
            result = sr.Append_List_Shared_Variables(shared_var, value.strip())
        return result
    except Exception:
        return CommonUtil.Exception_Handler(sys.exc_info())
common_functions.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def sequential_actions_settings(data_set):
    ''' Test Step front end for modifying certain variables used by Sequential Actions '''

    sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
    CommonUtil.ExecLog(sModuleInfo,"Function Start", 0)

    try:
        # Parse data set
        tmp = data_set[0][2].replace(' ', '').strip() # Get key and value from Value field and clean them
        shared_var = tmp.split('=')[0].strip().lower() # Retrieve variable name
        value = tmp.replace(shared_var + '=', '').strip() # Retrieve value for variable

        # Verify this is a real variable (should be set somewhere else)
        if not sr.Test_Shared_Variables(shared_var):
            CommonUtil.ExecLog(sModuleInfo,"The variable name specified (%s) is not a valid Sequential Action variable" % str(shared_var), 3)
            return 'failed'

        # Save variable - all functions that use this variable will now use the new value
        CommonUtil.ExecLog(sModuleInfo,"Changing Sequential Action setting of %s from %s to %s" % (str(shared_var), str(sr.Get_Shared_Variables(shared_var)), str(value)), 1)
        return sr.Set_Shared_Variables(shared_var, value)
    except Exception:
        return CommonUtil.Exception_Handler(sys.exc_info())
BuiltInFunctionSharedResources.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def Set_List_Shared_Variables(list_name, key, value, protected = False):
    try:
        sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
        global shared_variables, protected_variables
        if key == '' or key == None or value == '' or value == None or list_name == '' or list_name == None:  # if input is invalid
            return "failed"
        else: # Valid input
            if protected: protected_variables.append(key) # Add to list of protected variables
            else: # Check if user is trying to overwrite a protected variable
                if key in protected_variables: # If we find a match, exit with failure
                    CommonUtil.ExecLog(sModuleInfo, "Error: You tried to overwrite protected variable '%s'. Please choose a different variable name." % key, 3)
                    return 'failed'

            # Good to proceed
            if list_name in shared_variables:
                shared_variables[list_name][key] = value
                CommonUtil.ExecLog(sModuleInfo, "In List '%s' Variable value of '%s' is set as: %s" % (list_name, key, value), 0)
                return "passed"
            else:
                CommonUtil.ExecLog(sModuleInfo,
                        "List named %s does not exist on shared variables, so cant insert new field to list" % list_name,
                        3)
                return "failed"
    except:
        CommonUtil.Exception_Handler(sys.exc_info())
BuiltInFunctionSharedResources.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def Get_Shared_Variables(key):
    try:
        sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
        global shared_variables
        if key == '' or key == None:  # if input is invalid
            return "failed"
        else:
            if key in shared_variables:
                value = shared_variables[key]
                CommonUtil.ExecLog(sModuleInfo, "Variable value of '%s' is: %s" % (str(key), value), 0)
                return value
            else:
                CommonUtil.ExecLog(sModuleInfo, "No Such variable named '%s' found in shared variables" % key, 3)
                return "failed"
    except:
        CommonUtil.Exception_Handler(sys.exc_info())
BuiltInFunctionSharedResources.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def Get_List_from_Shared_Variables(list_name):
    try:
        sModuleInfo = inspect.stack()[0][3] + " : " + inspect.getmoduleinfo(__file__).name
        global shared_variables
        if list_name == '' or list_name == None:  # if input is invalid
            return "failed"
        else:
            if list_name in shared_variables:
                list = shared_variables[list_name]
                CommonUtil.ExecLog(sModuleInfo, "List: " + list_name + " is: " + str(list), 1)
                return list
            else:
                CommonUtil.ExecLog(sModuleInfo, "List named %s does not exist on shared variables" % list_name, 3)
                return "failed"
    except:
        CommonUtil.Exception_Handler(sys.exc_info())


问题


面经


文章

微信
公众号

扫码关注公众号