基於Ruby的Watir-WebDriver自動化測試方案

來源:互聯網
上載者:User

標籤:style   blog   http   color   os   ar   java   for   strong   

Watir-WebDriver

                自動化測試方案書

 

系統架構

該自動化測試架構分三個模組:Test用例、Control控制層、Tools工具類、Index總控。

Test用例
  1. 基於ruby的watir-webdriver開發
  2. 統一預置參數輸入規則,提供規則模板,做到一個用例一個類,一個方法一個輸出。(一個類可以多個方法)
  3. 統一輸出規則,比如:①[info]②TiStone ③Login successful!④001011

    ①   [Info]:代表該用例執行成功![error]代表失敗![warn]代表警告!

    ②   TiStone:代表執行用例名稱

    ③   Login successful!:描述或捕獲的value值,以“!”結尾

    ④   001011:返回碼

  4.統一用例名稱,應與輸出②保持一致

Control控制層
  1. 一個用例對應一個Control
  2. 效驗輸出,判斷用例執行成敗,根據規則關聯Linux伺服器捕獲相關日誌、設定檔等分析失敗原因,縮減定位地區範圍。
  3. 對比資料,關聯MySql查詢資料,對比web捕獲value值。
Tools工具類
  1. 封裝工具類
  2. 關聯Linux與MySql
  3. 提供測試案例支援,降低用例開發難度
Index總控
  1. 控制用例執行與展示
方案設計Test用例

涉及依賴:

require ‘watir-webdriver‘require ‘watir-webdriver-performance‘

頁面涉及:

元素捕獲

詳情可見:http://www.cnblogs.com/Javame/p/4045229.html

 

頁面載入效能監控

1.times do b.goto("https://192.168.10.1/web")load_secs = b.performance.summary[:response_time]/1000puts "Load Time: #{load_secs} seconds."End

 

功能成敗判別

if b.text.include? ‘T_100M‘            #捕獲web屬性value值            #後續操作            puts "①[info]②TiStone ③Login successful!000000" else            #後續操作            #輸出錯誤碼            puts "①[error]②TiStone ③Login failed!001011" end

 

參數化提取

class BasicNumber    def initialize(number,name)        @number = number        @name = name    end    def add(x)        @number + x    endend
Control控制層

涉及依賴:

load ‘Linux.rb‘load ‘MySql.rb‘

 

具體實現需與田利榮討論,商議具體商務邏輯的可測試性。

Tools工具類

涉及依賴:

require ‘net/ssh‘require ‘scp/ssh‘require "test/unit"

 

關聯Linux

#ip/使用者名稱/密碼host = "192.168.48.233"username = "root"password = "root"#調用linux命令server_cmd1 = ‘tail -1000 /home/log/web.log  | grep ERROR‘server_shell= ‘sh /home/wyong/w.sh‘

 

關聯MySql

具體實現略…

 

單元測試

class TC_MyTest  < Test::Unit::TestCase         def test_add                   n=BasicNumber.new(10)                   assert_equal(134,n.add(4),"This test about add is failure!")      endend
Index總控

涉及依賴:

load Control_用例名稱.rb‘

 

統一調用

t = Control_用例名稱.newtest_methods = t.public_methods.grep(/^test_/)test_methods.each do |test|  t.send(test) end

 

頁面展示

涉及Ruby Web開發架構,後期需要再行開發

 

基於Ruby的Watir-WebDriver自動化測試方案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.