2015年2月11日 星期三

RobotFramework - 使用不同的瀏覽器執行測試腳本

使用 Chrome/IE 執行 Web Application 測試腳本

  1.  命令列執行時,傳入瀏覽器名稱 (建議)
    @{BROWSERS} 維持單一值,使用指令執行時再傳入參數值,如下:
    $ pybot --variable BROWSER:firefox --argumentfile e2e.argfile.txt ./e2e
    $ pybot --variable BROWSER:chrome --argumentfile e2e.argfile.txt ./e2e
  2. 使用 for loop
    @{BROWSERS} 有多個設定值, 使用 for loop 執行
    *** Variables ***
    @{BROWSERS}          firefox  chrome  IE
    
    *** test cases ***
    test with several browser
        :FOR  ${browser}  IN   @{BROWSERS}
        \  log to console  call keyword that does your test with ${browser}

    執行測試:
    $ pybot --argumentfile e2e.argfile.txt ./e2e
    
    |   Browser.Ts
    |   ====================================================
    |   test with several browser
    |   call keyword that does your test with firefox
    |   call keyword that does your test with chrome
    |   call keyword that does your test with IE
    |   test with several browser                    | PASS |
    |   -----------------------------------------------------
    |   Browser.Ts                                   | PASS |
    |   1 critical test, 1 passed, 0 failed
    |   1 test total, 1 passed, 0 failed
    |   =====================================================
    
Reference: How can we pass different browser at once in robotframework

沒有留言:

張貼留言