[Wtr-general] Selecting an 'accented character' from a list

Paul Carvalho tester.paul at gmail.com
Fri Mar 2 12:13:17 EST 2007


Hi John, this may or may not be useful but when I work with accented items
like these, I treat them like a black box.  That is, I don't look into the
box to see how Ruby translates them .. which may or may not be how Ruby
really sees them.  In your select_list, can you refer to that "service name"
item by index instead of by text?

Not being a real programmer, I don't know if how I do things is the right
way or not, but I make *a lot* of use of arrays.  When I need to navigate
between names with accented characters, I drop all the contents into arrays
and then navigate by id and index numbers instead.  Hashes are really good
to me sometimes.

I spent some time months ago doing the same kinds of code magic translations
that you are proposing below but I gave up in frustration after a few days.
In my case, it looked like what Ruby showed me and what it really saw were
not the same thing, so I found it was best not to look at all.

Again, this might not help you, but it's how I managed to get around a
similar problem.  I don't know what your scripts do.  My scripts just kind
of randomly choose whatever data they need on the fly so no two runs are
ever the same.  I think the only data that I know my scripts reuse are the
user ID and password to log into the system.  Everything else sits in
randomly-created or selected variables and arrays.  I let Ruby work with
whatever data it finds.

I know.  It's weird.  But that's how I test, so I've programmed my scripts
to work the same way I do.  ;-)

Best of luck!  Cheers.  Paul C.


On 02/03/07, John Lolis <forum-watir-users at openqa.org> wrote:
>
> Looking for a bit of help here.
>
> I have a select list that has the following value 'Nome do serviço'.
>
> When I do select_list(whatever).text i get back 'Nome do servi\347o'
>
> if i look in the source of the html i get 'Nome do servi&#231;o'
>
> I also found code to convert 'Nome do serviço' to 'Nome do servi&#231;o'
> (but thats not what ruby sees)
>
> so...
>
> I need a way to convert 'Nome do serviço' to 'Nome do servi\347o' (i
> think...)
>
> # Code to convert from 'Nome do serviço' to 'Nome do servi&#231;o'
> # stolen from somwhere
>
> def entities( str )
>   converted = []
>   str.split(//).collect { |c| converted << ( c[0] > 127 ? "&##{c[0]};" : c
> ) }
>   converted.join('')
> end
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20070302/36ef9834/attachment.html 


More information about the Wtr-general mailing list