首页 > watir > firewatir 1.6.5不支持中文字符

firewatir 1.6.5不支持中文字符

2010年1月7日 leleba 发表评论 阅读评论

想了很多办法,包括更改.rb文件和firefox浏览器的编码,都不能用firewatir 1.6.5往网页上输入中文字符,测试的代码如下:

require ‘rubygems’
require ‘firewatir’

ff = FireWatir::Firefox.new
ff.goto “http://www.google.com

sleep 1
ff.text_field(:name, ‘q’).set(‘电’)

我还利用了以下语句,同样没有效果:

g_word = ‘电’
puts g_word
g_word_gb = Iconv.iconv(“GB2312//IGNORE”,”UTF-8//IGNORE”,g_word)
puts g_word_gb

sleep 1
ff.text_field(:name, ‘q’).set(g_word_gb[0])

或者:

g_word = ‘电’
puts g_word
g_word_utf = Iconv.iconv(“UTF-8//IGNORE”,”GB2312//IGNORE”,g_word)
puts g_word_utf

sleep 1
ff.text_field(:name, ‘q’).set(g_word_utf[0])

对于Watir 1.6.5, 将\Ruby\lib\ruby\gems\1.8\gems\watir-1.6.5\lib\watir\win32ole.rb文件中的语句 WIN32OLE.codepage = WIN32OLE::CP_UTF8 替换成 WIN32OLE.codepage = WIN32OLE::CP_ACP,即可让watir支持中文字符。



分类: watir 标签:
  1. sss
    2010年5月4日13:23 | #1

    firewaitr是通过JSSH对firefox进行操作,我也遇到这个问题,至今无法解决,希望能多交流交流

  1. 本文目前尚无任何 trackbacks 和 pingbacks.
      
                  
      

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word