Automation 机器人框架“未找到资源文件”错误

Automation 机器人框架“未找到资源文件”错误,automation,robotframework,Automation,Robotframework,我设计了这个体系结构,其中所有测试用例都在Amazon.robot文件中,robot框架的所有低级关键字都在两个单独的文件amazongui.robot和Commons.robot中 包含所有测试用例的Amazon.robot文件: *** Settings *** Documentation This is some basic infor the whole suite Resource Resources/AmazonGui.robot Resource Resources/Comm

我设计了这个体系结构,其中所有测试用例都在Amazon.robot文件中,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调用低级别关键字filecommon.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结果测试/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

此问题是因为没有为资源文件设置正确的路径。尝试此代码替换旧代码:

Resource  ../Resources/AmazonGui.robot
Resource  ../Resources/Common.robot

您将测试用例放在一个名为tests的文件夹中。资源文件位于另一个名为Resources的文件夹中

当你给予

Resources/AmazonGui.robot
它将在目录测试中检查名为Resources的目录,但实际上该目录位于测试目录之外

../Resources/AmazonGui.robot

在这里,您要求框架离开tests目录并检查名为Resources的目录。

您的测试用例位于一个名为tests的文件夹中。资源文件位于另一个名为Resources的文件夹中

当你给予

Resources/AmazonGui.robot
它将在目录测试中检查名为Resources的目录,但实际上该目录位于测试目录之外

../Resources/AmazonGui.robot

在这里,您要求框架离开tests目录,并检查名为Resources的目录。

我没有检查RF官方文档,但我以前遇到过这个问题。我认为入口是tests/amazon.robot,所以您应该基于amazon.robot的路径来导入资源文件……我没有与RF官方文档核对,但我以前遇到过这个问题。我认为入口是tests/amazon.robot,因此您应该基于amazon.robot的路径来导入资源文件。。。