机器人框架 "resource file not found" 错误
Robot framework "resource file not found" error
我设计了这个架构,其中所有测试用例都在 Amazon.robot 文件中,机器人框架的所有低级关键字都在两个单独的文件中(AmazonGui.robot 和 Commons.robot )
Amazon.robot 包含所有测试用例的文件:
*** Settings ***
Documentation This is some basic infor the whole suite
Resource Resources/AmazonGui.robot
Resource Resources/Common.robot
*** Variables ***
*** Test Cases ***
User must sign in to check out
[Documentation] This is some basic info about test
[Tags] Smoke
Common.Begin Web Test
AmazonGui.Search for Products
AmazonGui.Select Product from Search Results
AmazonGui.Add Product to Cart
AmazonGui.Begin Checkout
Common.End Web Test
我还有两个其他资源文件具有低级关键字,所以基本上测试用例 (Amazon.robot) 正在调用低级关键字文件 (Common.robot 和 AmazonGui.robot)。我已经将资源文件导入到测试用例文件中。
AmazonGui.robot 包含用于测试用例的低级关键字的文件
*** Settings ***
Library Selenium2Library
*** Keywords ***
Search for Products
go to http://www.amazon.com
wait until page contains Your Amazon.com
input text id=twotabsearchtextbox Ferrari 458
click button xpath=//*[@id='nav-search']/form/div[2]/div/input
wait until page contains results for "Ferrari 458"
Select Product from Search Results
click link css=#result_0 a.s-access-detail-page
wait until page contains Back to search results
Add Product to Cart
click button id=add-to-cart-button
wait until page contains Added to Cart
Begin Checkout
click link id=hlb-ptc-btn-native
page should contain element id=signInSubmit
Common.robot 具有共同特征的文件只是打开和关闭浏览器
*** Settings ***
Library Selenium2Library
*** Keywords ***
Begin Web Test
open browser about:blank ff
End Web Test
close browser
当我尝试使用 运行 来自终端的脚本时:
C:\development\robot-scripts\amazon>pybot -d 结果tests/amazon.robot
我收到以下错误:
[ ERROR ] Error in file 'C:\development\robot-scripts\amazon\tests\amazon.robot': Resource file 'Resources\AmazonGui.robot' does not exist.
[ ERROR ] Error in file 'C:\development\robot-scripts\amazon\tests\amazon.robot': Resource file 'Resources\Common.robot' does not exist.
==============================================================================
Amazon :: This is some basic infor the whole suite
==============================================================================
User must sign in to check out :: This is some basic info about test | FAIL |
No keyword with name 'Common.Begin Web Test' found.
--------------------------------------------------------
Amazon :: This is some basic infor the whole suite | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
不太确定,我应该去哪里查找问题。
这个问题是没有为资源文件设置正确的路径。试试这个代码替换旧的:
Resource ../Resources/AmazonGui.robot
Resource ../Resources/Common.robot
您的测试用例位于名为 tests 的文件夹中。资源文件存在于名为 Resources 的不同文件夹中。
当你给
Resources/AmazonGui.robot
它将检查目录 tests 中名为 Resources 的目录,但实际上该目录存在于 tests 目录之外。
../Resources/AmazonGui.robot
在这里,您要求框架从测试目录外部检查名为 Resources 的目录。
我设计了这个架构,其中所有测试用例都在 Amazon.robot 文件中,机器人框架的所有低级关键字都在两个单独的文件中(AmazonGui.robot 和 Commons.robot )
Amazon.robot 包含所有测试用例的文件:
*** Settings ***
Documentation This is some basic infor the whole suite
Resource Resources/AmazonGui.robot
Resource Resources/Common.robot
*** Variables ***
*** Test Cases ***
User must sign in to check out
[Documentation] This is some basic info about test
[Tags] Smoke
Common.Begin Web Test
AmazonGui.Search for Products
AmazonGui.Select Product from Search Results
AmazonGui.Add Product to Cart
AmazonGui.Begin Checkout
Common.End Web Test
我还有两个其他资源文件具有低级关键字,所以基本上测试用例 (Amazon.robot) 正在调用低级关键字文件 (Common.robot 和 AmazonGui.robot)。我已经将资源文件导入到测试用例文件中。
AmazonGui.robot 包含用于测试用例的低级关键字的文件
*** Settings ***
Library Selenium2Library
*** Keywords ***
Search for Products
go to http://www.amazon.com
wait until page contains Your Amazon.com
input text id=twotabsearchtextbox Ferrari 458
click button xpath=//*[@id='nav-search']/form/div[2]/div/input
wait until page contains results for "Ferrari 458"
Select Product from Search Results
click link css=#result_0 a.s-access-detail-page
wait until page contains Back to search results
Add Product to Cart
click button id=add-to-cart-button
wait until page contains Added to Cart
Begin Checkout
click link id=hlb-ptc-btn-native
page should contain element id=signInSubmit
Common.robot 具有共同特征的文件只是打开和关闭浏览器
*** Settings ***
Library Selenium2Library
*** Keywords ***
Begin Web Test
open browser about:blank ff
End Web Test
close browser
当我尝试使用 运行 来自终端的脚本时:
C:\development\robot-scripts\amazon>pybot -d 结果tests/amazon.robot
我收到以下错误:
[ ERROR ] Error in file 'C:\development\robot-scripts\amazon\tests\amazon.robot': Resource file 'Resources\AmazonGui.robot' does not exist.
[ ERROR ] Error in file 'C:\development\robot-scripts\amazon\tests\amazon.robot': Resource file 'Resources\Common.robot' does not exist.
==============================================================================
Amazon :: This is some basic infor the whole suite
==============================================================================
User must sign in to check out :: This is some basic info about test | FAIL |
No keyword with name 'Common.Begin Web Test' found.
--------------------------------------------------------
Amazon :: This is some basic infor the whole suite | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
不太确定,我应该去哪里查找问题。
这个问题是没有为资源文件设置正确的路径。试试这个代码替换旧的:
Resource ../Resources/AmazonGui.robot
Resource ../Resources/Common.robot
您的测试用例位于名为 tests 的文件夹中。资源文件存在于名为 Resources 的不同文件夹中。
当你给
Resources/AmazonGui.robot
它将检查目录 tests 中名为 Resources 的目录,但实际上该目录存在于 tests 目录之外。
../Resources/AmazonGui.robot
在这里,您要求框架从测试目录外部检查名为 Resources 的目录。