Hi!
To perform a simple conversion:
ie.text_field(:name, 'Amount').set('100')
ie.select_list(:name, 'From').select('USD United States Dollars')
ie.select_list(:name, 'To').select('JPY Japan Yen')
ie.button(:class, 'sprite nhgobtn').click
I'm not sure what you mean by loop code - are you trying to select
each available entry in the 'From' and 'To' currency dropdowns? If
you're not performing data-driven tests and just need the available
options:
from_options = ie.select_list(:name, 'From').options
to_options = ie.select_list(:name, 'To').options
-or-
from_options = ie.select_list(:name, 'From').getAllContents
to_options = ie.select_list(:name, 'To').getAllContents
You can then cycle through the options:
#cycle through each from option
from_options.each do |from_option|
#cycle through each to option
to_options.each do |to_option|
ie.goto('www.xe.com')
ie.text_field(:name, 'Amount').set('100')
ie.select_list(:name, 'From').select(from_option)
ie.select_list(:name, 'To').select(to_option)
ie.button(:class, 'sprite nhgobtn').click
end
end
I've tried to use the 'Convert Again' option, but clicking it using
each available parameter:
ie.button(:src, /btn_go/).click
ie.button(:alt, 'Submit').click
ie.button(:index, 1).click
gives the error 'There are no search results for this search. You may
want to talk to your development team to see if there is some other
action you need to perform. In the mean time, the best I can do is to
always go back to the home page.
FYI - When I tested my code above, the site caused IE to crash, the
next time, instead of being taken to 'www.xe.com' as I expected, I was
taken to 'www.xe.com/ucc'. This site does not appear to behave
consistently.
Also, you may have trouble automating this site because of the
continuous refreshing due to the advertising. I'm not sure what the
timing is - if you perform your actions before the refresh time, you
may be OK.
Hope this helps!
-Tiffany
On Jan 3, 9:57 am, Rinku Dev <[email protected]> wrote:
> Hi,
>
> I am new to Watir.
> I wanted to automate a web application, where there are two dropdown
> listbox with each 5 items listed.
>
> The scenario is "Currency conversion".
> We have to enter a value in a textbox and select the listed items from
> the two listboxes and click OK button and to get the value other
> textbox.
>
> e.g. The "XE Quick Currency Converter" section ofhttp://www.xe.com/
> 1. Go tohttp://www.xe.com/
> 2. Enter the currency value (for which we need to get the converted
> currency value)
> 3. Select one option from "From this currency:" dropdown listbox
> 4. Select one option from "To this currency:" dropdown listbox
> 5. Click on "GO" button
>
> Here, I would like to get help on the the TWO dropdown listboxes. Plz
> help me out to get the loop code, that will handle the TWO dropdown
> listboxes.
>
> Regards,
> - RDev
--
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To post to this group, send email to [email protected]
Before posting, please read the following guidelines:
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/watir-general