Anne,
one way to tackle that is to launch IRB, get @browser and evaluate
expression:
@browser.p(:after?, @browser.h3(:index, 12)).text
Also, I've found this series of blog posts on character encodings in
Ruby extremely useful:
http://blog.grayproductions.net/articles/understanding_m17n
BTW, this area changed quite a bit in Ruby 1.9, and now Watir is
compatible with Ruby 1.9, so you might want to look into upgrading Ruby
first.
I just went through the Ruby upgrade for my Watir tests and it was not
too bad.
--
DK
AIM: DKroot1, Skype: DKroot
On 7/5/11 3:36 PM, Anne wrote:
I have a web page that contains some Japanese characters.
In my test, I'm trying to compare the string from the web page with a
pre-defined string in my test script (the expected result). I'm just
not sure how to represent the Japanese characters (I've been
struggling with regular expressions and am still fairly new to ruby/
watir). I get the text from the screen and store it in a variable
using:
salesJapan = @browser.p(:after?, @browser.h3(:index, 12)).text
the expected results are stored in another variable,
expectedSalesJapan
but
How do I represent the Japanese characters in expectedJapanData? I've
tried copying the text from the web page source and escaping the
special characters but I haven't been able to get it right. (HTML is
below)
I'm using Ruby 1.8.7 and watir 1.9.0
------------------------
HTML: (only encoding defined in the HTML is charset=UTF-8)
<h3 id="japan">Japan</h3>
<p class="indented">
カスタマーサービス—日本国内
<br />
営業時間 平日午前9時から午後6時
<br />
Phone: +81 5-5555-5555<br />
Email:<a href="#" onclick="openEmailForm('japan'); return
false;">[email protected]</a> <br />
Fax: +81 5-5555-5555<br />
<a href="/home/about/toc.html?locale=jp">目次</a> Table of
contents
</p>
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]