SPONSORS:






User Tag List

Results 1 to 7 of 7
  1. #1
    Junior Member
    Join Date
    Jun 2001
    Location
    Amesbury
    Posts
    24
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Waiting for browser page to load

    How do I programatically get my script to wait for my page to appear?

    In the Windows Application world I used in while() statment waiting for the window to Exist.

    In my IE application, just prior to an action on the page that I'm waiting for I inserted:

    while (!TheVanPackingList.TheVanV22OnEASTWOOD1.Exists (2))

    Which is the recorded windows Identifier. This worked in my windows app for other small dialogs that I needed to wait for.

    I have 2 screens in my app that have variable execution times. Any help would be greatly appreciated.

    ------------------
    Steven E. Price
    Senior Quality Assurance Engineer
    Virtual Access Networks
    (978) 722 - 7122
    Steven E. Price
    Senior Quality Assurance Engineer
    Virtual Access Networks
    (978) 722 - 7122

  2. #2
    Senior Member
    Join Date
    Jun 1999
    Location
    Fremont, CA, USA
    Posts
    355
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Waiting for browser page to load

    You do about the same thing in the SilkTest world...


    ------------------
    David Genrich
    david@e2Open.com
    david_kim@usa.net

  3. #3
    Senior Member
    Join Date
    Jul 2001
    Posts
    147
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Waiting for browser page to load

    You want to add a counter, just in case the page never loads, otherwise it will get stuck in the while loop.

    Integer Counter = 0

    while (!Window.Exists() && Counter < 30)
    Sleep (1)
    Counter = Counter + 1

    ------------------
    Who Tests The Tester...
    Who Tests The Tester...

  4. #4
    Junior Member
    Join Date
    Jun 2001
    Location
    Amesbury
    Posts
    24
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Waiting for browser page to load

    Thanks to both of you:

    A follow-up would be; Do I have to place the window def into a window variable or should 4-test allow me to do inline as I attempted to do (just curiouse)? Also I thought that Exist() accepts a parameter that essentially does the same thing as the wait()?

    I think the counter is also a great idea.

    ------------------
    Steven E. Price
    Senior Quality Assurance Engineer
    Virtual Access Networks
    (978) 722 - 7122
    Steven E. Price
    Senior Quality Assurance Engineer
    Virtual Access Networks
    (978) 722 - 7122

  5. #5
    Senior Member
    Join Date
    Jul 1999
    Location
    Bellingham, WA USA
    Posts
    1,323
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Waiting for browser page to load

    You should be able to do as you originally proposed in your question.

    As to the wait in the Exists( ) method, that value defines the number of literal seconds to keep looking for your object to appear. You could place a 30 in there and it will look for thirty seconds and move to the next assigned operation. If that Exists(30) is in your loop however, you will be pausing 30 seconds with each pass looking for your window or object. This could be a very long process if the window never appears.

    I will typically do an inline check as you have proposed with a value something like myWindow.Exists(2) and if it does not, I'll do a Sleep(1) as David has shown.

    On a side note, I've occasionally had reliability issues with the while loop, and sometimes find greater success with a boolean bFound = myWindow.Exists(2) and then while !bFound sleep and look for the window again.

    Just a thought.

    ------------------

  6. #6
    Senior Member
    Join Date
    Jul 2001
    Location
    Elizabeth, CO, USA
    Posts
    653
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Waiting for browser page to load

    Here's a function I often use to deal with just such timing issues. Might help.

    This allows you to optionally set timeout and frequency variables. This will, however, raise an error if the object hasn't appeared in the specified amount of time. Which may or may not be your desire. At the same time, if it was so important for the object to be there and it isn't, raising an error will terminate the testcase, avoiding the inevitable error raise by SilkTest that it can't act on an object because it isn't there.

    And yes, you can either pass in a delcared object or a dynamically isntantiated one....
    I hope this helps.

    - Dave


    ------------------
    Amelior Technology
    dreed@ameliortech.com
    WaltzingRhino.com
    A concerned Borland customer, a fly in the ointment, a wrench in the works.

  7. #7
    Senior Member
    Join Date
    Nov 2000
    Location
    Bloomington, IL
    Posts
    142
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Waiting for browser page to load

    Here is another function to do the same thing. I use it when I want to be very specific.[+] CheckForInactive(WINDOW w, WINDOW wCont, WINDOW wCObj, INTEGER iTime)
    [ ] //************************************************** ************************************************
    [ ] //* This function checks for timeout activity when loading a new page into the browser
    [ ] //* The timeout is set (in seconds) by the iTime variable passed in. The w variable
    [ ] //* tells the function what window it is waiting to load.
    [ ] //************************************************** ************************************************
    [ ] INTEGER iWLoop = 1
    [ ] INTEGER iIError = 0
    [ ] INTEGER iTVal
    [ ] STRING sMaint
    [ ]
    [ ] StartTimer(PLTimer)
    [ ]
    [+] withoptions
    [ ] BindAgentOption(OPT_APPREADY_RETRY,1)
    [ ] BindAgentOption(OPT_APPREADY_TIMEOUT,iTime)
    [ ] BindAgentOption(OPT_VERIFY_APPREADY,FALSE)
    [+] do
    [+] while !(w.Exists ()) //While the designated window does not exist
    [ ] sleep(1)
    [ ] //If the number of loops executed in this function is greater than the passed seconds to test for
    [+] if iWLoop > iTime
    [ ] Browser.Stop.SetFocus()
    [ ] Browser.Stop.Click()
    [ ] sleep(10)
    [+] if w.Exists()
    [ ] continue
    [+] else
    [ ] LogWarning("Timeout for window {w}.") //Log a warning to the results (.res) file
    [+] withoptions
    [ ] BindAgentOption(OPT_VERIFY_ACTIVE,FALSE)
    [ ] Browser.Stop.SetFocus() //Set the browser active
    [ ] Browser.Stop.Click() //Click the Browsers Stop button
    [ ] iIError++ //Increment the internal error counter
    [+] if iIError < 2 //If the internal error counter is less than 1
    [+] if wCont.Exists()
    [ ] wCont.SetActive()
    [ ] wCObj.Click() //Click on the button to move to the next page
    [ ] iWLoop = 0 //Reset the internal loop counter
    [+] else
    [ ] Print("Wrong screen loaded, expected {w}.")
    [+] else //If the internal error counter is 2 or greater
    [ ] LogError("Timeout error for window {w}.")
    [ ] break

    //I call a function that looks for known error screens to provide more error information

    [ ] iWLoop++ //Increment the internal loop counter
    [ ]
    [ ] sTimeVal = TimerStopStorage(PLTimer, "Page")
    [ ] sTimeVal = ConvertMinToSec(sTimeVal)
    [ ] iTVal = Val(sTimeVal)
    [ ]

    //I call a function to write the elapsed time to a database

    [+] except
    [ ] sTimeVal = TimerStopStorage(PLTimer, "Page")
    [ ] iTVal = Val(sTimeVal)

    //I call a function to write the elapsed time to a database


    [ ] RaiseError(11, "CheckForInactive Failed")


    MikeF



    ------------------

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 05:34 AM.

Copyright BetaSoft Inc.