当前位置: 首页>>代码示例>>Python>>正文


Python BuiltIn.BuiltIn方法代码示例

本文整理汇总了Python中robot.libraries.BuiltIn.BuiltIn方法的典型用法代码示例。如果您正苦于以下问题:Python BuiltIn.BuiltIn方法的具体用法?Python BuiltIn.BuiltIn怎么用?Python BuiltIn.BuiltIn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在robot.libraries.BuiltIn的用法示例。


在下文中一共展示了BuiltIn.BuiltIn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from robot.libraries import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn import BuiltIn [as 别名]
def __init__(self):
        # save builtin so we dont have to re-create then everytime
        self.builtin = BuiltIn()

        # Need to create a testscript
        try:
            self._pyats_testscript = self.builtin.get_library_instance('pyats.robot.'
                                                                       'pyATSRobot').testscript
        except RuntimeError:
            try:
                self._pyats_testscript = self.builtin.get_library_instance('ats.robot.'
                                                                           'pyATSRobot').testscript
            except RuntimeError:
                # no pyATS
                pass
        finally:
            self._genie_testscript = TestScript(Testscript) 
开发者ID:CiscoTestAutomation,项目名称:CL-DevNet-2595,代码行数:19,代码来源:GenieRobot.py

示例2: __init__

# 需要导入模块: from robot.libraries import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn import BuiltIn [as 别名]
def __init__(self):
        # save builtin so we dont have to re-create then everytime
        self.builtin = BuiltIn()

        # Need to create a testscript
        try:
            self._pyats_testscript = self.builtin.get_library_instance('pyats.robot.'
                                                                       'pyATSRobot').testscript
        except RobotNotRunningError:
            # during libdoc generation
            pass
        except RuntimeError:
            try:
                self._pyats_testscript = self.builtin.get_library_instance('ats.robot.'
                                                                           'pyATSRobot').testscript
            except RuntimeError:
                # no pyATS
                pass
        finally:
            self._genie_testscript = TestScript(Testscript) 
开发者ID:CiscoTestAutomation,项目名称:genielibs,代码行数:22,代码来源:GenieRobot.py

示例3: __init__

# 需要导入模块: from robot.libraries import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn import BuiltIn [as 别名]
def __init__(self, *args):
        self.builtin = BuiltIn()
        logger.debug("initializing PageObjects...")
        importer = robot.utils.Importer()

        for file_path in args:
            try:
                importer.import_class_or_module_by_path(os.path.abspath(file_path))
                logger.debug("imported page object {}".format(file_path))
            except Exception as e:
                logger.warn(str(e))
        self.current_page_object = None

        # Start with this library at the front of the library search order;
        # that may change as page objects are loaded.
        try:
            self.builtin.set_library_search_order("PageObjects")
        except RobotNotRunningError:
            # this should only happen when trying to load this library
            # via the robot_libdoc task, in which case we don't care
            # whether this throws an error or not.
            pass 
开发者ID:SFDO-Tooling,项目名称:CumulusCI,代码行数:24,代码来源:PageObjects.py

示例4: add_location_strategies

# 需要导入模块: from robot.libraries import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn import BuiltIn [as 别名]
def add_location_strategies():
    """Call selenium's add_location_strategy keyword for all strategies"""

    # selenium throws an error if the location strategy already
    # exists, so we use a flag to make sure this code is called
    # only once.
    selenium = BuiltIn().get_library_instance("SeleniumLibrary")
    for (prefix, strategy) in LOCATORS.items():
        try:
            BuiltIn().log(f"adding location strategy for '{prefix}'", "DEBUG")
            if isinstance(strategy, dict):
                selenium.add_location_strategy(
                    prefix, functools.partial(locate_element, prefix)
                )
            else:
                # not a dict? Just pass it through to selenium as-is
                # so that this function can register normal keywords
                selenium.add_location_strategy(prefix, strategy)
        except Exception as e:
            BuiltIn().log(f"unable to register locators: {e}", "DEBUG") 
开发者ID:SFDO-Tooling,项目名称:CumulusCI,代码行数:22,代码来源:locator_manager.py

示例5: locate_element

# 需要导入模块: from robot.libraries import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn import BuiltIn [as 别名]
def locate_element(prefix, parent, locator, tag, constraints):
    """This is the function called by SeleniumLibrary when a custom locator
    strategy is used (eg: cci:foo.bar). We pass an additional argument,
    prefix, so we know which set of locators to use.

    This tokenizes the locator and then does a lookup in the dictionary associated
    with the given prefix. If any arguments are present, they are applied with
    .format() before being used to find an element.
    """

    # Ideally we should call get_webelements (plural) and filter
    # the results based on the tag and constraints arguments, but
    # the documentation on those arguments is virtually nil and
    # SeleniumLibrary's filter mechanism is a private function. In
    # practice it probably won't matter <shrug>.
    selenium = BuiltIn().get_library_instance("SeleniumLibrary")
    loc = translate_locator(prefix, locator)
    BuiltIn().log(f"locate_element: '{prefix}:{locator}' => {loc}", "DEBUG")
    try:
        element = selenium.get_webelement(loc)
    except Exception:
        raise Exception(
            f"Element with locator '{prefix}:{locator}' not found\ntranslated: '{loc}'"
        )
    return element 
开发者ID:SFDO-Tooling,项目名称:CumulusCI,代码行数:27,代码来源:locator_manager.py

示例6: test_no_implicit_wait

# 需要导入模块: from robot.libraries import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn import BuiltIn [as 别名]
def test_no_implicit_wait(self, mock_get_library_instance):
        """Verify the "implicit wait" context manager restores the value"""

        selib = BuiltIn().get_library_instance("SeleniumLibrary")
        selib.set_selenium_implicit_wait.return_value = 7
        selib.set_selenium_implicit_wait.reset_mock()

        page = BasePage()
        with page._no_implicit_wait():
            pass

        # The first call should pass in zero to turn off the
        # implicit wait.  We've configured the mocked function to
        # return '7'. The second call should pass the return value
        # of the first call
        selib.set_selenium_implicit_wait.assert_has_calls(
            (mock.call(0), mock.call(7)), any_order=False
        ) 
开发者ID:SFDO-Tooling,项目名称:CumulusCI,代码行数:20,代码来源:test_pageobjects.py

示例7: test_no_implicit_wait_with_exception

# 需要导入模块: from robot.libraries import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn import BuiltIn [as 别名]
def test_no_implicit_wait_with_exception(self, mock_get_library_instance):
        """Verify the "implicit wait" context manager restores the value even if exception occurs"""

        selib = BuiltIn().get_library_instance("SeleniumLibrary")
        selib.set_selenium_implicit_wait.return_value = 42
        selib.set_selenium_implicit_wait.reset_mock()

        page = BasePage()
        try:
            with page._no_implicit_wait():
                raise Exception("Danger Will Robinson!")
        except Exception:
            pass

        # The first call should pass in zero to turn off the
        # implicit wait.  We've configured the mocked function to
        # return '42'. The second call should pass the return value
        # of the first call
        selib.set_selenium_implicit_wait.assert_has_calls(
            (mock.call(0), mock.call(42)), any_order=False
        ) 
开发者ID:SFDO-Tooling,项目名称:CumulusCI,代码行数:23,代码来源:test_pageobjects.py

示例8: set_capture_format

# 需要导入模块: from robot.libraries import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn import BuiltIn [as 别名]
def set_capture_format(self,format):
        """ Sets the format for the screen capture file

        The format does not include the default prefix ``.png``
        The default format is ``<mod>_%010d``. ``mod`` could be ``samurai`` or
        ``arbor``

        See https://docs.python.org/2/library/string.html#format-specification-mini-language
        for more details about the format string.

        Examples:
        | Samurai.`Set Capture Format`  | ${case}_%010d |  # ${case} is a predefined variable |

        """
        name = self._current_name
        self._browsers[name]['capture_format'] = format
        BuiltIn().log("Changed the screenshot capture format to `%s`" % format) 
开发者ID:bachng2017,项目名称:RENAT,代码行数:19,代码来源:WebApp.py

示例9: connect_all

# 需要导入模块: from robot.libraries import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn import BuiltIn [as 别名]
def connect_all(self):
        """ Connects to all applications defined in ``local.yaml``

        The name of the connection will be the same of the `webapp` name
        """
        num = 0
        if 'webapp' in Common.LOCAL and Common.LOCAL['webapp']:
            for entry in Common.LOCAL['webapp']:
                device = Common.LOCAL['webapp'][entry]['device']
                type = Common.GLOBAL['device'][device]['type']
                if type.startswith(self._type):
                    num += 1
                    self.connect(entry,entry)
                    BuiltIn().log("Connected to %d applications" % num)
        else:
            BuiltIn().log("WARNING: No application to connect") 
开发者ID:bachng2017,项目名称:RENAT,代码行数:18,代码来源:WebApp.py

示例10: power_off

# 需要导入模块: from robot.libraries import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn import BuiltIn [as 别名]
def power_off(self,vm_name,graceful=True):
    """ Shutdowns a VM

    If `graceful` is True, a graceful shutdown is tried before a power off.

    *Note*: if VMware tools is not install on the VM, graceful shutdown is not
    available
    """
    target_vm = _get_vm(self,vm_name)
    if graceful:
        cmd = 'vim-cmd vmsvc/power.shutdown %s' % target_vm._moId
        output = _ssh_cmd(self,cmd)

    if ('VMware Tools is not running' in output) or ('Invalid fault' in output):
        cmd = 'vim-cmd vmsvc/power.off %s' % target_vm._moId
        output = _ssh_cmd(self,cmd)

    BuiltIn().log('Shutdown the VM `%s`' % vm_name) 
开发者ID:bachng2017,项目名称:RENAT,代码行数:20,代码来源:vmware.py

示例11: send_mks_keys

# 需要导入模块: from robot.libraries import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn import BuiltIn [as 别名]
def send_mks_keys(self,keys,wait='5s'):
    """ Sends key strokes to current web console

    Special Ctrl char could be used as ``${CTRL_A}`` to ``${CTRL_Z}``

    Examples:
    | `Send MKS Key`   |     ${CTRL_L} |

    *Notes*: For other usable key value, see Selenium document
    """
    driver = BuiltIn().get_library_instance('SeleniumLibrary')
    canvas = driver.get_webelement('mainCanvas')
    if len(keys) == 1 and ord(keys) < ord('@'):
        canvas.send_keys(Keys.CONTROL + chr(ord(keys) + ord('@')))
    else:
        canvas.send_keys(keys)
    time.sleep(DateTime.convert_time(wait))
    BuiltIn().log('Sent keystrokes to the web console') 
开发者ID:bachng2017,项目名称:RENAT,代码行数:20,代码来源:vmware.py

示例12: _delete_conn_info

# 需要导入模块: from robot.libraries import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn import BuiltIn [as 别名]
def _delete_conn_info(self, switch, port, dir):
    """ Deletes existed connection between ``port1`` and ``port2`` an the switch

    ``dir`` could be ``bi``,``in`` or ``out``
    """
    cli     = self._clients[switch]
    ip      = cli["ip"]
    conn_port  = cli["port"]
    session = cli["session"]

    if dir == 'bi':     direction = 'DUPLEX'
    if dir == 'in':     direction = 'INPUT'
    if dir == 'out':    direction = 'OUTPUT'

    rest_result = session.delete('http://%s:%s/rest/v1/connect/' % (ip,conn_port,port))
    if rest_result.status_code != requests.codes.ok:
        BuiltIn().log("Failed to delete the x-connection")
        return False
    else:
        BuiltIn().log("Deleted x-connection of port `%s` on switch %s" % (port,switch))

    return True 
开发者ID:bachng2017,项目名称:RENAT,代码行数:24,代码来源:g4ntm.py

示例13: load_config

# 需要导入模块: from robot.libraries import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn import BuiltIn [as 别名]
def load_config(self,config_name='',force=True):
    """ Loads test configuration
    config_name is defined in ``local.yaml`` or specific by user in the main
    scenario.
    """
    BuiltIn().log("Load test configuration")
    cli = self._clients[self._cur_name]
    ix  = cli['connection']
    if config_name == '':
        config_name = Common.LOCAL['tester'][self._cur_name]['config']

    config_path = Common.get_item_config_path() + '/' + config_name

    service = self._base_url + '/bps/upload'
    files = {'file': (config_name,open(config_path,'rb'),'application/xml')}
    jdata = {'force':force}
    result = ix.post(service,files=files,data=jdata,verify=False)

    if result.status_code != requests.codes.ok:
        BuiltIn().log(result.text)
        raise Exception('ERROR: could not logout')
    self._config_path = config_path
    BuiltIn().log("Loaded configuration file `%s`" % config_path) 
开发者ID:bachng2017,项目名称:RENAT,代码行数:25,代码来源:ixbps.py

示例14: get_test_report

# 需要导入模块: from robot.libraries import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn import BuiltIn [as 别名]
def get_test_report(self,report_name='result',format='csv'):
    """ Gets and saves the test report to local disk

    The report will be in PDF format. If ``export_csv`` is ``True`` then test
    results are also exported by CSV format.
    """
    cli = self._clients[self._cur_name]
    ix  = cli['connection']
    result_path = Common.get_result_path()
    report_path = result_path + '/' + report_name + '.' + format
    service = self._base_url + '/bps/export/report/%s/%s'

    result = ix.get(service % (self._test_id,format),verify=False,stream=True)
    if result.status_code != requests.codes.ok:
        BuiltIn().log(result.text)
        raise Exception('ERROR: could not get test report')
    else:
        with open(report_path,'wb') as file:
            result.raw.decode_content = True
            shutil.copyfileobj(result.raw,file)

    BuiltIn().log("Got test reports by name `%s` with format `%s`" % (report_name,format)) 
开发者ID:bachng2017,项目名称:RENAT,代码行数:24,代码来源:ixbps.py

示例15: get_card_config

# 需要导入模块: from robot.libraries import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn import BuiltIn [as 别名]
def get_card_config(self,slot_num):
    """ Get card configuration for `slot_num`

    Parameter:
    - `slot_num` is `all` or an integer start from 1

    Result is a json formatted string contains the informaition for specific
    slot or `all` slots.
    """
    cli = self._clients[self._cur_name]
    ix  = cli['connection']
    service = self._base_url + '/bps/ports/chassisconfig'
    result = ix.get(service)
    if result.status_code != requests.codes.ok:
        BuiltIn().log(result.text)
        raise Exception('ERROR: could not release ports `%s`' %json.dumps(payload))

    jresult = json.loads(result.text)
    if slot_num in ['all','All','ALL']:
        card_info = jresult
    else:
        card_info = jresult[str(slot_num)]
    BuiltIn().log('Got slot configuration for slot `%s`' % str(slot_num))
    return card_info 
开发者ID:bachng2017,项目名称:RENAT,代码行数:26,代码来源:ixbps.py


注:本文中的robot.libraries.BuiltIn.BuiltIn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。