当我在 Windows7+Ruby1.9.2+watir-webdriver 上执行这个测试脚本时:
# encoding: utf-8
require "rubygems"
require "watir-webdriver"
ie = Watir::Browser.new :ie
ie.goto "www.tilde.eu"
ie.select_list(:name => "tr-direction").select "Latvian-English"
ie.select_list(:name => "tr-direction").selected? "Latvian-English"
ie.text_field(:class => "tr-area").set "skolas dārzā aug divas priedes"
ie.element_by_xpath("/html/body/div[3]/div/div/div/section/div/div/div/form/table/tbody/tr/td[3]/input").click
Watir::Wait.until { ie.text.include? "About Tilde Machine Translation" }
puts ie.div(:class => "translate_text_result").text
脚本在 Firefox 中执行良好,但 IE9 在尝试在文本字段中设置“ā”字母时崩溃,CMD 显示如下:
No translation for key. Assuming unicode input: 257
Timeout awaiting keypress: 82
Key up failed: 1400
Key down failed: 1400
Timeout awaiting keypress: 90
Key up failed: 1400
No translation for key. Assuming unicode input: 257
Key down failed: 1400
脚本在 Chrome 中完全执行,但在 CMD 中仍然显示一些警告:
Started ChromeDriver
port=52409
version=14.0.836.0
[0825/095000:WARNING:webdriver_key_converter.cc(271)] No translation for key code. Code point: 257
[0825/095000:WARNING:webdriver_key_converter.cc(271)] No translation for key code. Code point: 257
# encoding: utf-8
除了在 IE 和 Chrome 中正常工作之外,我是否需要指定其他任何内容?
我建议在您的计算机上执行上述脚本,以确定这是常见问题还是我的配置中的问题。