Hi Bill,

Thsi is my actual script-
Script
-------
#User experience script to capture response time

#Load the library and create reference to Library object
require 'watir'
require 'watir/win32ole'
require 'logger'
#include Watir

# hack ruby logger to format and output only the minimum needed for
testing scripts
# Logger is configured to write
class Logger
  # hack format of logger
  class Formatter
    #original: Format = "%s, [%s#%d] %5s -- %s: %s\n"
    #Change the name of constant to avoid redefining the super which
bugs us a bit. So let it be Formato then.
    Formato = "[%s] [%5s] : %s\n"

    #keep the original signature but alter implementation to change
formatting

    def call(severity, time, progname, msg)
      #add logging to stdout
      puts output_message = msg2str(msg)
      STDOUT.flush
      #original: Format % [severity[0..0], format_datetime(time), $$,
severity, progname, msg2str(msg)]
      Formato % [format_datetime(time),severity, output_message]
    end
  end
end

#Create a log file
time = Time.now.strftime("%Y-%m-%d")
logfile = File.join('D:/ruby/log', "test_#{time}.csv")
$log = Logger.new(logfile,'daily')
$log.level = Logger::INFO
$log.datetime_format = "%Y-%m-%d %H:%M:%S"
$log.info("Started.")

#Create a new IE object
$ie = Watir::IE.new

#variables
test_site = 'http://testsite.net'


#Go to the website
begin_time = Time.now
$ie.goto(test_site)
$ie.maximize
$log.info('Hit the testsite URL,'+'Time taken to load Home page: '+
$ie.down_load_time.to_s)


#Login to testsite
$ie.text_field(:name, "userName").set("user1")
$ie.text_field(:name, "password").set('u1')
$ie.button(:value, "Login").click
$log.info('Login to testsite,'+'Time taken to load Home page: '+
$ie.down_load_time.to_s)

#Click on products tab
$ie.image(:name, 'toplogo_nav_04_off').click

Watir::Waiter.wait_until(360, 1){
begin
puts image.width
true
rescue
false
end
}

$log.info('Click on products tab,'+'Time taken to load Products page:
'+$ie.down_load_time.to_s)
$log.info($ie.images.length)

----
# When my script run "$ie.image(:name, 'toplogo_nav_04_off').click ",
the product page appears.The page layout sucsessfully gets loaded and
in IE status bar it says done. After that it starts rendering the
product images (these are the main images).
The product images to render takes a long time.currently the
application has only 14 product images.in future these images may get
increase up to 200.
Current behavior: As i have mentioned 360 seconds, within that time
period all 14 product images loaded successfully ,also get visible and
after 360 seconds the timeout exception is thrown on console and the
script exist.

My aim:- to capture the page load time after loading successfully all
the product images.
1> How to wait for the product images to load properly and visible on
UI
2> how I will verify whether all the product images has loaded or not.
if all the images is loaded then automatically my script will go to
the next step to execute.
3. once the page gets laoded completely with al product images then it
should record the page load time.


the below mentioned information gets displayed for each product.
I am giving the info from the source

          prodID = '4028480d22a786ea0122a833029a0085';
          prodName = 'Test product1';

          productImage = 'showSmallProductImage.htm?
productId='+prodID;

          productCode = 'DC-00100002';

          releaseDate = '05-Mar-2009';
          description = 'Test description';


I am not able to get the success in this script. Please help me to
make the changes in the script. This is very urgent.
Please help.

Thanks
Maumita

On Aug 20, 10:00 pm, Bill Agee <[email protected]> wrote:
> According to the rdoc for the wait_until method, you can provide your own
> timeout value:
>
> http://wtr.rubyforge.org/rdoc/classes/Watir/Waiter.html
>
> So maybe something like this will work for you:
>
> wait_until(360, 1) { BLOCK }
>
> In that example 360 is the total number of seconds to wait, and 1 is the
> polling interval.
>
> Thanks
> Bill
>
> On Thu, Aug 20, 2009 at 4:19 AM, Maumita <[email protected]> wrote:
>
> > I have read the topics mentioned by you. I already have used the
> > wait_until method..but after 60 secs I got the time out error. And my
> > webpage within the time perioed is not able to display the product
> > images on UI. The product images to display on UI is taking time.Some
> > time it takes 5 minutes..sometime more than that..
>
> > Is there anyway that my script will wait untill all product images are
> > loaded and displayed properly?
> > Or is there anyway to verify that all the images on the page are
> > visible or not?
>
> > In this scenario, how I will capture the page load time?
>
> > On Aug 20, 3:03 pm, Željko Filipin <[email protected]>
> > wrote:
> > > Have you read this?
>
> > >http://wiki.openqa.org/display/WTR/How+to+wait+with+Watir
>
> > > Željko
> > > --http://watirpodcast.com/
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to