獲取對象屬性值的方法

方法1:
require 'watir'
$ie = Watir::IE.new
$ie.goto 'http://www.google.cn/'
def messlg(value,re)
  x=[]
  $ie.text_field(:name=>value).to_s.each   do
     |d| x.unshift(d)
  end
0.upto(x.length-1) do |t|
   s=x[t].split(":")
  if  s[0].strip ==re
  puts s[1].strip
  end
 end
end

messlg('q',"type")


====》text



方法2:
puts $ie.text_field(:name,'q').attribute_value("type")

===》text



方法3:
p ie.button(:name,"btnG").class_name

====》1st


發佈了53 篇原創文章 · 獲贊 9 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章