On Friday, March 29, 2013 12:55:10 PM UTC-7, johnssn wrote:

> Think this will work, although there may be some better way of doing it. I 
> was using watir-webdriver and firefox:
>
> b.goto('http://www.proflowers.com')
> b.text_field(:value => " Keyword / Item #").set "30046508"
> b.div(:id, 'SearchContainer').image(:class, 'searchSubmit').click
> b.image(:class, 'calendar_button').click
> b.div(:class, "5_1_2013 weekday").click
>
> You can use a Time object to format the class string in the last command 
> to select the day you want. 
>
> #8 days from now:
> [56] pry(main)> t = Time.now + 691200
> => 2013-03-30 12:21:36 -0700
>
> Then you can use the Time object's strftime method to format the modified 
> time as a string in m_d_yyyy format. See 
> http://ruby-doc.org/stdlib-1.9.3/libdoc/time/rdoc/Time.html for more info.
>  
>
>
Most of that looks pretty good to me.  for the Go button, The image tag is 
inside of a link container of type img, and the link has an ID (which 
hopefully is fairly static). So in that case since the image is mostly 
there to provide visual content for that link, I'd suggest you try clicking 
the link itself.  I think this will work (but have not had time to test it) 
  

browser.link(:id => "productDetailBody_ctl12_ctl80_submit2").click

The calendar icon also has an ID, so if using class does not work (in case 
the class is associated with another similar icon) then you could also try 
using the id attribute to identify that one

browser.img(:id => "productDetailBody_deliveryCalendar_Image1").click

Clicking the calendar icon is a little tricker.  Johnssn has the right 
approach to use ruby date classes to do the date math for you. Then you 
need to format that into something that looks like "4_11_2013" assigning 
that string to a variable.   Since the class of the divs inside that 
calendar has the date in it, you should be able to click either that div, 
or maybe it's parent, to select that day    (you may need to do some other 
magic to know what days are available, or check if the class of the parent 
indicates a deliverable day or not, and if not increment the date.. 

targetdate = "4_11_2013"
browser.div(:class => targetdate).click    #<--inner div with date as a 
class
browser.div(:class => targetdate).parent.click  #<--parent div, in case 
that's what has to be clicked
if browser.div(:class => targetdate).parent.attribute_value("class") == "
deliveryUnavailable" 
 # do something to adjust the date, if the date you picked would not work
end



>  

-- 
-- 
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]

--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to