0

我想從測試 例 月1日我的路徑創建一個路徑爲1次,保存截圖的截圖動態路徑是如何設置機器人框架的部分

*** Setting *** 
Library  Selenium2Library screenshot_root_directory=/Users/person/Documents/testrobot/screenshot30-01-2017 12-00-00 

第二個我的路徑是

*** Setting *** 
Library  Selenium2Library screenshot_root_directory=/Users/person/Documents/testrobot/screenshot30-01-2017 12-30-00 

如何設置動態路徑

我的機器人代碼

*** Setting *** 
Library  Selenium2Library screenshot_root_directory=/Users/person/Documents/testrobot/screenshot 
Library  DateTime 
*** Variables *** 

*** Keywords *** 

*** Test Cases *** 

謝謝

回答

1

首先指定你想要的屏幕截圖將保存在目錄 - 並設置堅持爲False,因爲它是一次性的東西 - 一個特定測試:

Set Screenshot Directory /Users/person/Documents/testrobot/screenshot30-01-2017 12-00-00 False 

然後完成了截圖 - 並檢查它是否存在:

${ScreenShotOne} Capture Page Screenshot Screenshot1.png 
File Should Exist /Users/person/Documents/testrobot/screenshot30-01-2017 12-00-00/Screenshot1.png 

然後,更改爲其他屏幕截圖direcotry:

Set Screenshot Directory /Users/person/Documents/testrobot/screenshot30-01-2017 12-30-00 

,然後填寫你在上面做了同樣的過程:

${ScreenShotTwo} Capture Page Screenshot Screenshot2.png 
File Should Exist /Users/person/Documents/testrobot/screenshot30-01-2017 12-30-00/Screenshot2.png 

你也可以只設置路徑,每次創建截圖:

${ScreenShotTwo} Capture Page Screenshot /Users/person/Documents/testrobot/screenshot30-01-2017 12-30-00/Screenshot2.png False 
File Should Exist /Users/person/Documents/testrobot/screenshot30-01-2017 12-30-00/Screenshot2.png 

所有這一切中發現Selenium2Library文檔:

Keyword: Capture Page Screenshot
在同一頁上Keyword: Set Screenshot Directory

1

@Goralight和我,但我創建全局變量爲關鍵字保存路徑

*** Setting *** 
Library  Selenium2Library 
Library  DateTime 

*** Variables *** 
${WEB} xxx.xxxxx.xxxx 
${BROWSER} chrome 
${TYPE OF FILE} png 
*** Keywords *** 

Get DateTime 
    ${date1}= Get Current Date result_format=%Y-%m-%d %H-%M-%S 
    [Return]  ${date1} 

Open Web 
    Open Browser ${WEB} ${BROWSER} 
    Maximize Browser Window 
    ${Date}= Get DateTime 
    Set Global Variable ${Path} /Users/person/Documents/testrobot/screenshot/${Date} 

Close Web 
    Close Window 

Screenshot 
    [Arguments] ${filename} 
    Set Screenshot Directory ${Path} 
    Wait Until Page Contains Element 
    # ${datetime}= Get DateTime 
    Capture Page Screenshot ${filename}.${TYPE OF FILE} 
    Log To Console ${\n}Screenshot 


*** Test Cases *** 

[1] Click Home 
    Open Web 

我的文件夾結果是

click

+0

你有沒有解決您的問題或沒有答案沒有解決它嗎?要麼? :s – Goralight

+1

我解決了我的問題:)並感謝您的回答,因爲它可以建立在我的工作上。 – Zeing