【发布时间】:2015-09-24 19:20:31
【问题描述】:
您可以使用导入资源导入文件吗?
我需要能够运行相同的测试用例但使用不同的变量才能以不同的语言运行相同的测试用例。为此,我创建了不同的资源库。
为了告诉我的测试用例哪个变量文件我运行了一个关键字来只导入那个国家的资源文件。
例如(这在 importAU 文本中,与 AU Resource.txt 共享相同的资源文件夹)
*** Keywords ***
AU
[Documentation] Initializes the AU keyword variables
Import Resource ../variables/AU/Resource.txt
然后这是设置 txt(打开浏览器并运行正确的文件)
*** Settings ***
Library Selenium2Library
Resource ../variables/US/Resource.txt
Resource ../variables/AU/Resource.txt
Resource ../variables/DE/Resource.txt
*** Variables ***
${COUNTRY} AU //sets which country the file should run
*** Keywords ***
Homepage should be open
Run Keyword AU
Set Selenium Speed 1 second
Open Browser ${url_staging} chrome
Set log level TRACE
Maximize Browser Window
我运行了这个,这是我得到的错误。
SETUP: setup.Homepage should be open
Start / End / Elapsed: 20150707 18:56:35.038 / 20150707 18:56:35.048 / 00:00:00.010
00:00:00.009 KEYWORD: BuiltIn.Run Keyword AU
Documentation:
Executes the given keyword with the given arguments.
Start / End / Elapsed: 20150707 18:56:35.039 / 20150707 18:56:35.048 / 00:00:00.009
00:00:00.007 KEYWORD: importau.AU
Documentation:
Initializes the AU keyword variables
Start / End / Elapsed: 20150707 18:56:35.040 / 20150707 18:56:35.047 / 00:00:00.007
00:00:00.006 KEYWORD: BuiltIn.Import Resource ../variables/AU/Resource.txt
Documentation:
Imports a resource file with the given path.
Start / End / Elapsed: 20150707 18:56:35.041 / 20150707 18:56:35.047 / 00:00:00.006
18:56:35.046 FAIL Resource file '..\variables\AU\Resource.txt' does not exist.
是我对关键字做错了什么还是关键字有问题?我知道这是 RobotFramework 的一个已知问题,但它应该已修复。
这里是链接:http://code.google.com/p/robotframework/issues/detail?id=944
【问题讨论】:
-
表示文件不存在,这是一个很明显的问题。您是否确认您在正确的目录中?也许您可以添加一些日志语句来验证您对相对路径的假设。
-
但是当我从设置文件中导入它们时,它会起作用吗?这是否意味着 Import Resource 上的路径应该与 txt 文件中的路径不同?
标签: robotframework