我设计了这个架构,其中所有测试用例都在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)。我已将Resources文件导入测试用例文件。
具有针对测试用例的低级关键字的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 results 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
不确定,我应该在哪里找出问题。
答案 0 :(得分:4)
您的测试用例位于名为tests的文件夹中。资源文件存在于名为Resources的不同文件夹中。
当你给出
Resources/AmazonGui.robot
它将在目录测试中检查名为Resources的目录,但实际上该目录位于tests目录之外。
../Resources/AmazonGui.robot
在这里,您要求框架来到tests目录之外,并检查名为Resources的目录。
答案 1 :(得分:2)
此问题是没有为资源文件设置正确的路径。试试这个代码替换旧:
Resource ../Resources/AmazonGui.robot
Resource ../Resources/Common.robot