Forum Discussion

mesg2anil's avatar
mesg2anil
Regular Contributor
15 years ago

Wait till page loads and Row and Column loop

Hi,



I have two questions, please help me...



Question1:

I want to use script to make the script wait till the web page is loaded completely, instead of using "Delay" what other option I've?

I more thing I want to mention is... while web page is being loaded... theURL will not change... for example, when I click on submit button the webpage will go to next page, in this situation the URL will not change it will be "http://server1/default.asp" always, so how to make the script wait till the page is loaded completely?



Question2:

I'm using below code to read excel file and loop the columns, but how to loop rows? If I want the script to read two rows and input the data to application; what further changes I need to be to the below code?



Function ReadPayVou (Fname,Sname)

Dim Driver,i

Set Driver =
DDT.ExcelDriver(Fname, Sname)

RecNo = 0

CreateSCArr1 = CreateVariantArray(0, 0)



'Record Loop

While Not DDT.CurrentDriver.EOF 

 



'Column Loop

For i = 0 To DDT.CurrentDriver.ColumnCount - 1

PropNum = PropertyCount

 



'Iterates through the properties

For j = 0 to (PropNum - 1)

PropName = Properties(j).Name

Next

Next

VarArrayRedim CreateSCArr1, RecNo

RecNo = RecNo + 1



DDT.CurrentDriver.Next()

WEnd



'Closing the driver

Call DDT.CloseDriver(Driver.Name)



End Function



Please suggest!!



Please suggest!!

4 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Question1:

    I want to use script to make the script wait till the web page is loaded completely, instead of using "Delay" what other option I've?

    I more thing I want to mention is... while web page is being loaded... theURL will not change... for example, when I click on submit button the webpage will go to next page, in this situation the URL will not change it will be "http://server1/default.asp" always, so how to make the script wait till the page is loaded completely?




    This is pretty easy, actually.  After you perform an action against the page, simply call the page object's "Wait method"



    pageObj = Aliases.browser.Page("http://www.mysite.com/")

    PerformActionAgainstPage

    pageObj.Wait()




    As for your second question... I'm not sure what you're asking... the DDT.CurrentDriver.Next() method is already "looping" the rows... Your while loop uses the "current" row and then, when you call that Next method, it goes to the next row.  So, effectively, your rows are looped.



    Now, if you mean how to only use the first two rows, all you need to do is add a counter that increments each time through your loop and then, in your "While" statement, add a condition "counter <= 2".
  • mesg2anil's avatar
    mesg2anil
    Regular Contributor
    Hi Robert,



    For Question1, as you suggested, I did the same thing in the code shown below...




    Set Contentframe = Sys.Process("iexplore", 2).Page("http://server1/Default.asp").document.frames.Frame("mainFrame").document.frames.Frame("ContentFrame").document.all

    Contentframe.Wait()  ==> "Unable to find the object Wait. See additional information for details"



    This is erroring out as mentioned above. Any suggestion please?


    Contentframe = .Process("iexplore", 2).Page("http://server1/Default.asp").document.frames.Frame("mainFrame").document.frames.Frame("ContentFrame").document.allContentframe.Wait()  ==> ""This is erroring out as mentioned above. Any suggestion please?
  • mesg2anil's avatar
    mesg2anil
    Regular Contributor
    Hi Robert,



    Forgot to mention one more point here...

    Acutally whenever I go to next page, my pageobj will change, so each time instead of giving different pageobj.wait(), how to make it a generic one so that i can give the generic pageobj.wait() instead of changing the pageobj each time the page objects changes?



    In your example, each time pageobj changes i need to give that particular pageobj.wait(), which is also erroring out as said in my above reply. Could you please suggest me the generic one? I think there is something we can do using Window("Internet Explorer_Server")??? If we set using Window("Internet Explorer_Server") to the pageobj, this pageobj can be used as a generic one throughout the script
  • Hi,



    Wait is a method of the Page object, not of specific page elements from which you call it.



    As for the changing page object, you just need to replace the URL with a wildcard. Also, if the new pages get loaded in the same browser window, the reference to the page object shouldn't change.