【老王公众号】

关于watir-webdriver中文乱码问题

 

require 'watir-webdriver'
require 'iconv'  
cov = Iconv.new( 'gbk', 'utf-8')     

b = Watir::Browser.new 


b.cookies.clear

b.goto("http://www.hao123.com")
  

#t = b.text_field :class => 'input input-hook'
#t.exists?
#t.set 'your name'
#t.value



a=b.button(:class=>'button button-hook').attribute_value("value")
 
puts cov.iconv("#{a}")

puts b.link(:xpath=>'//*[@id="__wgt_0_28"]/li[4]/span[4]/a').text()

#b.span(:xpath=>'//*[@id="hao123-footer"]/div[1]/span[5]').flash

#puts b.span(:class=>"g-fc2 copyright").text



#attribute_value("value")

#puts #{a}
#
#a.flash
#t.set 'ddd'

 

posted @ 2014-12-24 14:10  CTO老王  阅读(701)  评论(0编辑  收藏  举报