您的位置:軟件測(cè)試 > 開源軟件測(cè)試 > 開源功能測(cè)試工具 > Watir
Watir--Web自動(dòng)化UI測(cè)試的框架
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2013/3/14 15:40:45 ] 推薦標(biāo)簽:

  Watir,Web ApplicationTestinginRuby. 它是Ruby語(yǔ)言下,一個(gè)自動(dòng)化UI測(cè)試的框架。對(duì)于Watir的測(cè)試框架,它對(duì)于ActiveX插件,JavaApplets, Flash, 或者其他的插件應(yīng)用程序基本不支持。如何確定您測(cè)試的頁(yè)面是否Watir支持,只要您在頁(yè)面中右擊出現(xiàn)View Source 選項(xiàng),那么Waitr基本支持。Watir還帶有AutoIt擴(kuò)展對(duì)Javascript彈出或者其他的彈出窗口。

  在Watir中的對(duì)象包括Hyperlinks, Checkboxes, Buttons, Forms, Radio buttons, Selection boxes, Text fields, Frames, Images, Tables等等。我們可以使用 ie.show_all_objects來(lái)顯示頁(yè)面中的所有元素,當(dāng)我們無(wú)法確定頁(yè)面對(duì)象是否被選中時(shí)可以使用flash方法,比如 ie.text_field(:name, “test_text”).flash。以下的對(duì)象屬性對(duì)于Watir的使用非常有用。比如 name,id,index,value,URL(links),Alt,SRC(images)。

  以下是Watir對(duì)于頁(yè)面的一些操作:

  Hyperlinks

  ie.link(:text, "link_name").click

  Checkboxes

  ie.checkbox(:name, “checkbox_name”, “value”).set

  ie.checkbox(:name, "checkbox_name").set

  ie.checkbox(:name, "checkme").clear

  Radio buttons

  ie.radio(:name, "clickme").set

  ie.radio(:name, “radio_name”, “value”).set

  ie.radio(:name, "clickme").clear

  Selection boxes

  ie.select_list( :name , "select_list_name").select("select_option")

  ie.select_list( :name , "selectme").clearSelection

  Text fields

  ie.text_field(:name, "field_name").set("Watir World")

  ie.text_field(:name, "typeinme").clear

  HTML Buttons

  ie.button(:value, "Click Me").click

  Forms

  ie.form(:name, "form_name").submit

  ie.form(:action, "action_name").submit

  Frames

  ie.show_frames# show all the frames existed in the same page

  ie.frame("menu").link(:text, "Click Menu Item").click# operate in frame

  Images

  ie.image(:name, “image_name”).click

  Tables

  ie.table(:id, “table_id”)

  Manipulate row

  row = ie.table(:index, 2)[2]    

              count=1     

              row.each do |cell|            

                           #fill in code to do an action or verifaction     

  end

  Manipulate cell

  cell = ie.table(:index, 2)[2][2]

我們將Table看作一個(gè)頁(yè)面, 我們能在上面檢索buttons,images,links,tables等等的對(duì)象。

  ie.row(:id, 'row1')

  ie.cell(:id, 'cell_id')

  ie.table(:index, 2)[2][2].table(:index,1)[1][1].text

  ie.table(:index, 2)[1][1].button(:name, “button_name”).click

  當(dāng)我們點(diǎn)擊按紐或者連接打開新的window,我們能使用attach去識(shí)別依靠新的window的URL或者Windowstitle。

  ie2 = Watir::IE.attach(:url, 'http://mytestsite')

  ie3 = Watir::IE.attach(:title, 'Test New Window')

  Watir也支持正則表達(dá)式,這對(duì)測(cè)試將是非常有用的,特別是對(duì)頁(yè)面對(duì)象進(jìn)行復(fù)雜驗(yàn)證時(shí)。

  JavaScript.彈出框比如警告窗口,系統(tǒng)安全彈出框以及其他不屬于頁(yè)面的窗口。我們得依靠AutoIt來(lái)操作了。

上一頁(yè)123下一頁(yè)
軟件測(cè)試工具 | 聯(lián)系我們 | 投訴建議 | 誠(chéng)聘英才 | 申請(qǐng)使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd