python - Robot Framework 中的静态变量

标签 python static robotframework

机器人框架中有静态类型变量之类的东西吗?如果是这样我该如何调用它?或者是通过 python 文件来实现的解决方案?

我试图解决的问题是,我希望设置一个变量一次并让它记住设置的值。不幸的是,这个变量位于资源文件中(它与我的测试套件文件分开)。

最佳答案

是的,您可以在机器人框架中设置静态变量。您的资源文件中应该有类似的内容。

*** Settings ***
...
*** Variables ***
${MyVariable}    MyValue

*** Keywords ***
...

你的测试应该是这样的

*** Settings ***  

Resource    (Path to resource file)

*** Test Cases ***
My Test Case
[Documentation]    This is documentation
My keyword    MyVariable

关于python - Robot Framework 中的静态变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54109182/

相关文章:

python - 复制了静态文件,未使用 css

selenium - 找不到正确的Xpath

java - 如何修复 - 41 : non-static variable cannot be referenced from a static context -> What is the reason for this?

c++ - 什么时候初始化全局静态常量变量?

xpath - 文本为两行时如何编写单个xpath

robotframework - 如何在机器人框架的 FOR 循环中使用 if/else 条件

python - 设置 GAE 命名空间

python - 如何从 np.genfromtxt 添加的 ndarray 中删除 'b' 字符

python - 无法安装 OpenCV python3.8

python - 在 python 上查找 Windows 和 Linux 的默认网关地址