2016-02-17 83 views
0

我設計了這種架構,其中所有的測試用例都將在Amazon.robot文件中,而機器人框架的所有低級關鍵字將位於兩個單獨的文件(AmazonGui.robot和Commons)中。機器人)機器人框架「找不到資源文件」錯誤

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 

剛剛打開的共同特點和關閉瀏覽器

*** Settings *** 
Library Selenium2Library 

*** Keywords *** 

Begin Web Test 
    open browser about:blank ff 


End Web Test 
    close browser 

Common.robot文件我試圖從終端使用腳本運行:

C:\研發\機器人腳本\亞馬遜> 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 

不能確定,我應該去找找出來問題。

Robot framework error

回答

1

你有你的測試用例在一個名爲tests的文件夾中。資源文件存在於名爲Resources的另一個文件夾中。

當你給

Resources/AmazonGui.robot 

它會在目錄測試將檢查一個名爲資源,但實際上該目錄目前該項測試目錄之外。

../Resources/AmazonGui.robot 

在這裏您要求框架出現在測試目錄之外,並檢查名爲Resources的目錄。

2

這個問題是沒有爲資源文件的正確道路。試試這個代碼替換舊的:

Resource ../Resources/AmazonGui.robot 
Resource ../Resources/Common.robot 
+0

如果能給出一點解釋,我會真的很感激。 –

+0

我沒有檢查RF官方文檔,但我之前遇到過這個問題。我認爲入口是tests/amazon.robot,所以你應該根據amazon.robot的路徑導入資源文件... – Stephen

相關問題