devya wrote:
> Case 2: Fails to set value for the to,subject and mailbody fields after few 
> iteration.
>
> login
> for 1 to 50
> sendmail
> logout
>
> In this case after sending the first, few mails, it shows the 
> to,subject,mailbody fields. The exists? test passes for these controls. 
>
> However setting the values on these controls does not reflect the 
> value in ie. Also, flash method does not flash it. When I read the 
> value from these controls, I can read them. 
>
> One interesting thing that I noted is, if I set
> the value in ie directly and then read the control, I dont get
> the new value, but what I get is the old value.
>
> Have I found a bug? Isn't watir refreshing the new DOM tree after
> sending the mail? 
>   
No, there isn't any bug in watir. However, its typical behavior of 
gmail. I am not sure why, but
this is what I observed after playing with gmail.

Every time you compose a mail, gmail puts mail compose control in either 
of the v1,v2,v3 or v4
frame. I have not been able to figure out exactly when it uses a given 
frame though. One thing
I noticed is that sometimes two frames contain the same controls for 
compose mail and hence
the above mentioned behavior. I modified the SendMailGmail() as follows 
and it worked for 50
iterations.

There are chances that the following code may not work in the case, when 
exists? check is
done on elements which are not displayed. I did not face this problem in 
first run.

However, the question is, is there any way to figure out if the controls 
are the one which are visible
in the ie? Can I use Z-Index attribute?

Regards,
Manish


def SendMailGmail(mailTo, mailSubject, mailBody)
  puts "In SendMailGmail function"
  @ie.send_keys("c")
  while(([EMAIL PROTECTED](:name, "main").frame(:id, "v1").text_field(:id, 
"to_compose").exists?) && ([EMAIL PROTECTED](:name, "main").frame(:id, 
"v2").text_field(:id, "to_compose").exists?) && ([EMAIL PROTECTED](:name, 
"main").frame(:id, "v3").text_field(:id, "to_compose").exists?) && 
([EMAIL PROTECTED](:name, "main").frame(:id, "v4").text_field(:id, 
"to_compose").exists?) )
    p "waiting for compose window to appear"
    sleep(2)
  end
  if ( @ie.frame(:name, "main").frame(:id, "v1").text_field(:id, 
"to_compose").exists? )
    frame="v1"
  elsif ( @ie.frame(:name, "main").frame(:id, "v2").text_field(:id, 
"to_compose").exists? )
    frame="v2"
    elsif ( @ie.frame(:name, "main").frame(:id, "v3").text_field(:id, 
"to_compose").exists? )
    frame="v3"
    else
      frame = "v4"
    end
  puts "chosen frame is #{frame}\n"
 # sleep(2)
  #if (@ie.frame(:name, "main").frame(:id, "v2").text_field(:id, 
"to_compose").exists?())
    puts "Mail To Address - #{mailTo}"
    @ie.frame(:name, "main").frame(:id, frame).text_field(:id, 
"to_compose").set(mailTo)
  #end 
  #if (@ie.frame(:name, "main").frame(:id, "v2").text_field(:name, 
"subject").exists?())
    puts "Mail Subject - #{mailSubject}"
    @ie.frame(:name, "main").frame(:id, frame).text_field(:name, 
"subject").set(mailSubject)
  #end
  #if (@ie.frame(:name, "main").frame(:id, "v2").div(:id, 
"hc_compose").exists?())
    puts "Mail Body - #{mailBody}"
    @ie.frame(:name, "main").frame(:id, frame).div(:id, 
"hc_compose").document.innerHTML=mailBody
  #end
  @ie.frame(:name, "main").frame(:id, frame).button(:id, "snd").click c
  @ie.frame(:name, "main").wait()
  sleep(3)
end # end function SendMail
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to