Jump to content

Wait for IE page to load


jharmon
 Share

Recommended Posts

I am quite new to this, and this is my first post, so I hope I provide enough information...

I am working on a script that searches through my open IE windows, finds the one that I am looking for, opens a form on that page, populates the fields based on answers provided in the GUI section of the script, and submits the entries. After .submit is run, the page loads a new unique form. I am wanting it to wait until that unique form's address is created and loaded, then I want to set a variable equal to the .service_no.value field. The following is the address of the new form and the surrounding code, and underlined is the unique part of the address.

With $ObjIE

.document.frames("Application").location.href = "http://VARIOUS_PAGE/createform.asp?form=wohead&selectedrecord=280674&link="

Do

Sleep(50)

Until .document.frames("Application").document.ReadyState = "complete"

EndWith

Is there anything I can put in place of the unique part so my script will wait for this new page to completely load without moving on? I am also looking to do this with without just having the script wait for a specified number of seconds due to the fact that on busy days, it can take up to 10-20 seconds for the page to fully load. Also, if I put in a number that was previously created as the unique portion, the script works properly, but loads the old form corresponding to the number entered.

If anyone is interested, more code is included in the output.doc file attached. The problem code is toward the bottom.

Thanks.

output.txt

Edited by jharmon
Link to comment
Share on other sites

There are probably a million solutions for this, especially with the beta version and IE.au3, but what I use to wait for a browser page to fully load is for the hourglass icon to disappear.

Func HourGlass()

Do

Sleep(1000)

Until MouseGetCursor()= 2

EndFunc

Hope this helps

Link to comment
Share on other sites

You ask:

Is there anything I can put in place of the unique part so my script will wait for this new page to completely load without moving on?

But I'm not certain what you are calling the "unique part" of your script. The .location.href is what I'd assume you were referring to, but it seems to be integral to what you are trying to display, so I don't imagine you are trying to replace that...

confused...

Dale

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

When .submit is clicked/run, a new form is created. A number is generated and added to a database along with all of the information that was entered previously (I do not have access to the database...only the forms created). The address of the new form is based around the number created which discerns it from every other form created. In this case the number is 280674 which should be underlined, bold, and red. I hope this makes things a little more clear. Sorry for the confusion.

Sorry fmen...I haven't had a chance to try your suggestion yet.

Link to comment
Share on other sites

The change of number, combined with the ready state of the browser object should be enough to trigger a new iteration. Just store the old number and compare to the new one after the web page status updates. Have you tried the IE3 UDF that Dale has so graciously shared with us?

Link to comment
Share on other sites

When .submit is clicked/run, a new form is created. A number is generated and added to a database along with all of the information that was entered previously (I do not have access to the database...only the forms created). The address of the new form is based around the number created which discerns it from every other form created. In this case the number is 280674 which should be underlined, bold, and red. I hope this makes things a little more clear. Sorry for the confusion.

Sorry fmen...I haven't had a chance to try your suggestion yet.

So what I confused about is that the href line:

.document.frames("Application").location.href = "http://VARIOUS_PAGE/createform.asp?form=wohead&selectedrecord=280674&link="
causes the frame to load the page you're specifying there. Are you not relying on that to load the page? If so, you can't change it, if you aren't then I really am missing the point of your question.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

I am relying on the href part to load the page, but every time .submit is clicked on the page prior, there is a new form created with a new number. I need the new number, but I have to wait for the new form to completely load. I can't use the link to 280674 every time. I also can't hack off the "&selectedrecord=280674&link=" because if I do, the very first form in the database is accessed and loaded. This is very hard to explain without seeing it. If you are confused, it is no big deal...I'll figure something out.

Link to comment
Share on other sites

I am relying on the href part to load the page, but every time .submit is clicked on the page prior, there is a new form created with a new number. I need the new number, but I have to wait for the new form to completely load. I can't use the link to 280674 every time. I also can't hack off the "&selectedrecord=280674&link=" because if I do, the very first form in the database is accessed and loaded. This is very hard to explain without seeing it. If you are confused, it is no big deal...I'll figure something out.

So let me try once more.

If the .submit results in a new page (and a new form) being displayed in the frame, why do you need the location.href command?

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Because that is what is in the source code and the address displayed in the address bar doesn't change, so I figure the

.document.frames("Application").location.href = "http://VARIOUS_PAGE/createform.asp?form=wohead&selectedrecord=280674&link="

is necessary for the frame to stay put and the correct form to load. If I still have lost you, don't worry about it...Thanks.

Link to comment
Share on other sites

Because that is what is in the source code and the address displayed in the address bar doesn't change, so I figure the

.document.frames("Application").location.href = "http://VARIOUS_PAGE/createform.asp?form=wohead&selectedrecord=280674&link="

is necessary for the frame to stay put and the correct form to load. If I still have lost you, don't worry about it...Thanks.

The address in the address bar does not change because it is pointing to an HTML document that defines the FRAMESET. The FRAMESET defines the number ond orientation of the frames on the page and the initial document (src=) that is loaded into each frame. The html document loaded into each frame can change based on actions taken in that frame or in other frames taht target their actions to that frame (e.g. <A Href="somepage.htm" target="a-frame-name">). This is what is happning when you submit the form in taht frame... the <FORM> tag has an ACTION= that will cause a new page to be loaded into that frame.

Now, if you issue the .document.frames("Application").location.href instruction you'll override the document that was loaded into the frame by the submission of the form. This is probably not what you want to do. If you need to be able to get to the new form that is displayed in the new document in that frame so that you can set a value in it and then .submit it again, you can do that simply by knowing the name of the frame that contains this document. The FRAMESET is part of the top-level document loaded in the browser, the individual FRAME is part of that FRAMESET, the document is a child of the frame and the form in the document can be accessed in the Document Object Model for that document.

You seem to be pretty comfortable with the DOM based on the code that you are working with, but you micht find that some of the functions in IE.au3 may simplify things for you or you can tear them apart to see what is going on under the covers.

good luck,

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Thank you everyone for your help. I ended up getting it with the following:

With $ObjIE

.Visible = True

Do

_IELoadWait($ObjIE)

Until .document.frames("Application").document.ReadyState = "complete"

EndWith

Well that's a pretty funky combination of commands... I would expect that thte following would have the same result:
Do 
    Sleep(100)
Until $ObjIE.document.frames("Application").document.ReadyState = "complete"

but if it works and you're happy, I'm happy.

Dale

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...