机器人框架-如何从pabot.PabotLib库开始?

时间:2018-11-02 08:53:19

标签: python robotframework

Pabot文档提供了一个示例来说明如何调用它,就像:

***Settings***
Library    pabot.PabotLib

*** Test Case ***
Testing PabotLib
    Acquire Lock   MyLock
    Log   This part is critical section
    Release Lock   MyLock

    ${valuesetname}=    Acquire Value Set
    ${host}=            Get Value From Set   host
    ${username}=        Get Value From Set   username
    ${password}=        Get Value From Set   password
    Log   Do something with the values (for example access host with username and password)

    Release Value Set
    Log   After value set release others can obtain the variable values

但是,我只可以“ Library pabot”,当我在RED RobotEditor和Pycharm中尝试“ Library pabot.PabotLib”时,它总是会提醒“未知的'pabot.PabotLib'库”。

如何在我的IDE中调用“ pabot.PabotLib”?

1 个答案:

答案 0 :(得分:0)

Pabot和RED以不同的方式处理Robot Framework。 RED的方法是实用的,将一次运行一个脚本/适合的脚本,从而允许诸如调试之类的复杂功能。 Pabot的方法是并行运行套件。 RED无法并行处理数据流,因此不应期望您可以使用与常规机械手方法相同的功能来运行它。

这就是为什么将pabot.PabotLib加载到RED也将不起作用的原因。但是,有一种方法可以识别库关键字。这将使从RED运行Pabot成为不可能,但至少将有助于编写脚本。

在“引用的库”部分的RED.xml中将以下XML作为libspec文件加载时。这样可以确保识别关键字和库。

pabot.PabotLib.xml

<?xml version="1.0" encoding="UTF-8"?>
<keywordspec name="pabot.PabotLib" type="library"
    format="ROBOT" generated="20181102 15:20:05">
    <version>0.28</version>
    <scope>global</scope>
    <namedargs>yes</namedargs>
    <doc>Documentation for test library ``pabot.PabotLib``.</doc>
    <kw name="Acquire Lock">
        <arguments>
            <arg>name</arg>
        </arguments>
        <doc>Wait for a lock with name.
            This will prevent other processes from acquiring the lock with
            the name while it is held. Thus they will wait in the position
            where they are acquiring the lock until the process that has it
            releases it.
        </doc>
        <tags>
        </tags>
    </kw>
    <kw name="Acquire Value Set">
        <arguments>
        </arguments>
        <doc>Reserve a set of values for this execution.
            No other process can reserve the same set of values while the set is
            reserved. Acquired value set needs to be released after use to allow
            other processes to access it.
        </doc>
        <tags>
        </tags>
    </kw>
    <kw name="Get Parallel Value For Key">
        <arguments>
            <arg>key</arg>
        </arguments>
        <doc>Get the value for a key. If there is no value for the key then
            empty
            string is returned.
        </doc>
        <tags>
        </tags>
    </kw>
    <kw name="Get Value From Set">
        <arguments>
            <arg>key</arg>
        </arguments>
        <doc>Get a value from previously reserved value set.</doc>
        <tags>
        </tags>
    </kw>
    <kw name="Release Lock">
        <arguments>
            <arg>name</arg>
        </arguments>
        <doc>Release a lock with name.
            This will enable others to acquire the lock.
        </doc>
        <tags>
        </tags>
    </kw>
    <kw name="Release Locks">
        <arguments>
        </arguments>
        <doc>Release all locks called by instance.</doc>
        <tags>
        </tags>
    </kw>
    <kw name="Release Value Set">
        <arguments>
        </arguments>
        <doc>Release a reserved value set so that other executions can use it
            also.</doc>
        <tags>
        </tags>
    </kw>
    <kw name="Run Only Once">
        <arguments>
            <arg>keyword</arg>
        </arguments>
        <doc>This is an *experimental* keyword for building setups that
            should be executed only once. As the keyword will be called
            only in one process and the return value could basically be anything.
            The "Run Only Once" can't return the actual value.
            If the keyword fails, "Run Only Once" fails.
            Others executing "Run Only Once" wait before going through this
            keyword before the actual command has been executed.
            NOTE! This is a potential "Shoot yourself in to knee" keyword
            Especially note that all the namespace changes are only visible
            in the process that actually executed the keyword.
            Also note that this might lead to odd situations if used inside
            of other keywords.
            Also at this point the keyword will be identified to be same
            if it has the same name.
        </doc>
        <tags>
        </tags>
    </kw>
    <kw name="Set Parallel Value For Key">
        <arguments>
            <arg>key</arg>
            <arg>value</arg>
        </arguments>
        <doc>Set a globally available key and value that can be accessed
            from all the pabot processes.
        </doc>
        <tags>
        </tags>
    </kw>
</keywordspec>
相关问题