From: Alex Schubert Date: 2012-07-21T16:37:45+09:00 Subject: AW: watir browser.button umlaut problem This is a multipart message in MIME format. ------=_NextPart_000_0105_01CD6724.7D7F49F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all =20 I didn't manage to solve the problem itself, but you may be interested = in knowing that I found a workaround. I figured out howto use regular expressions for object recognition, in = this case the browser button name. Search for a substring of the button name, which does not contain an = Umlaut character and uniquely identifies it. =20 Example =20 if browser.button(:value, /hle 6 Zufallszahlen/).exist? browser.button(:value, / hle 6 Zufallszahlen /).click end =20 regards Alex =20 Von: a.schubert@datacomm.ch [mailto:a.schubert@datacomm.ch]=20 Gesendet: Sonntag, 15. Juli 2012 19:28 An: ruby-talk ML Betreff: watir browser.button umlaut problem =20 Hi all =20 I am automating some simple Web application testing using watir, i e clicking on browser buttons, selecting an item from a dropdown list etc. Everything I got working except the following. The script should click on browser buttons that contain Umlaut = characters in its name (German =F6 for example). Example of a button name "W=E4hle 6 Zufallszahlen" =20 Problem: The script exists with the following error =20 C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic= /el ement.rb:66:in `assert_exists': Unable to locate element, using {:tag_name=3D>["button", "submit", "image", "reset"], = :value=3D>"W\xE4hle 6 Zufallszahlen"} (Watir::Exception::UnknownObjectException) =20 ---- Begin script extract ------------------------------------------------------------------- #encoding: ISO-8859-1 require 'watir' =20 browser =3D Watir::Browser.start "http://gahq.hopto.org/lotto/lotto.php" =20 browser.button(:value,"W=E4hle 6 Zufallszahlen").click ----End script extract -------------------------------------------------------------------- =20 I thought the #encoding ISO-8859-1 ... at the beginning could help. = Without this line (or encoding set to UTF-8 etc) the script would exit with the error ruby-lotto4b.rb:18: invalid multibyte char (US-ASCII) ruby-lotto4b.rb:18: syntax error, unexpected tIDENTIFIER, expecting ')' browser.button(:value,"W=E4hle 6 Zufallszahlen").click =20 I searched the forum archive, but couldn't spot any information how-to resolve the problem. =20 Has someone encountered the problem as well and found a solution? I am using Ruby 1.9.3-p194 on Win7, browser IE9 =20 Regards Alex Schubert =20 ------=_NextPart_000_0105_01CD6724.7D7F49F0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

Hi all

 

I didn't manage to solve = the problem itself, but you may be interested in knowing that I found a = workaround.

I figured out howto use regular expressions for = object recognition, in this case the browser button = name.

Search for a substring of the button name, which = does not contain an Umlaut character and uniquely identifies = it.

 

Example

 

=A0 if = browser.button(:value, /hle 6 = Zufallszahlen/).exist?

=A0=A0=A0 browser.button(:value, / hle 6 = Zufallszahlen /).click

=A0 end

 

regards

Alex

 

Von: a.schubert@datacomm.ch [mailto:a.schubert@datacomm.ch] =
Gesendet: Sonntag, 15. Juli 2012 19:28
An: = ruby-talk ML
Betreff: watir browser.button umlaut = problem

 

Hi = all

 

I am automating some simple Web application testing = using watir, i e clicking on browser buttons, selecting an item from a = dropdown list etc. Everything I got working except the = following.

The script should click on = browser buttons that contain Umlaut characters in its name (German =F6 = for example). Example of a button name "W=E4hle 6 = Zufallszahlen"

 

Problem: The = script exists with the following error   

C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0= /lib/watir-classic/element.rb:66:in `assert_exists': Unable to locate = element, using {:tag_name=3D>["button", "submit", = "image", "reset"], :value=3D>"W\xE4hle 6 = Zufallszahlen"} = (Watir::Exception::UnknownObjectException)

 

---- Begin = script extract = -------------------------------------------------------------------<= /o:p>

#encoding: ISO-8859-1

require 'watir'

 

browser =3D = Watir::Browser.start "http://gahq.hopto.org/lott= o/lotto.php"

 

  = browser.button(:value,"W=E4hle 6 = Zufallszahlen").click

----End script extract = --------------------------------------------------------------------=

 

I thought the #encoding ISO-8859-1 ... at the = beginning could help. Without this line (or encoding set to UTF-8 etc) = the script would exit with the error

ruby-lotto4b.rb:18: invalid multibyte char = (US-ASCII)

ruby-lotto4b.rb:18: syntax = error, unexpected tIDENTIFIER, expecting ')' = browser.button(:value,"W=E4hle 6 = Zufallszahlen").click

 

I searched = the forum archive, but couldn't spot any information how-to resolve the = problem.

 

Has someone encountered the problem as well and found = a solution?

I am using Ruby = 1.9.3-p194  on Win7, browser IE9

 

Regards

Alex Schubert

 

------=_NextPart_000_0105_01CD6724.7D7F49F0--