Jump to content

Working with IE and waiting for something to change in a webpage


Recommended Posts

Hi, I'm hoping someone would take pity on me and help me out. Don't know a lot about programming or scripting (the last time I had to program was in college when computers had 64k memories and no HDDs)

Anyway, here's what I want to accomplish:

Task 1.log on to a web page. Now since the page designers left out naming objects on forms I had to hijack their html source code and make my own. The script I have works. The only problem is that I have to log on multiple accounts one after the other and I'm pretty sure doing it this way is unattractive.

It would have helped if there was a way to just determine a form object type and select it for input using an index, much like the _IELinkClickByIndex function.

This is what I have so far.

#include <IE.au3>

$oIE = _IECreate("c:\login.html")
_IELoadWait ($oIE)
$oForm = _IEFormGetObjByName ($oIE, "glogin")
$oUser = _IEFormElementGetObjByName ($oForm, "user")
_IEFormElementSetValue ($oUser, "****")
$oPass = _IEFormElementGetObjByName ($oForm, "pass")
_IEFormElementSetValue ($oPass, "****")
_IEFormSubmit ($oForm)
_IELoadWait ($oIE)

Since the form doesn't have a name for the objects in it, I can't just set the value that's why I had to code a seperate HTML doc that have form objects with names to get started. This becomes stupidly tedious and would mean that after I log out, I need to close the browser and again launch another one right after to log in my next set of credentials.

Task 2. After logging in, I need to click on a specific link and check if a timer has run down. I got the clicking part using _IELinkClickByIndex but I can not get how I'm supposed to read the timer. The timer isn't fixed and it's random anywhere from 30mins to days. I need to read the clock, determine if the clock has run down so I can perform the next task or log out and log on using the next set of credentials.

Task 3. Store the value of the timer. If it has not run down to zero yet, I need to store the time left before it runs down and use that to determine when the current set of credentials is supposed to log back on.

Task 4. If the timer has run down, I need to select a drop down object/control from a form and then submit that form. Then I need to get the value of the timer that comes up and store that so that the script knows when this set of credentials is supposed to log back on.

I think I can handle the drop down thingy but then when the page reloads after I hit submit, I have no way again of getting the timer and storing the time left.

Task 5. log out and wait for a timer from a set of credentials to run down before I log that credential back in.

(optional) Task 6. On one account, i need to determine how long before a certain text changes into something else. Ummm, let's say from "Sending.." to "Received." and I need to write the elapsed time between the changes to a text file. I know how to write the text file, I just dont know how to get autoit to read that specific part of the page that has the text and record the time elapsed between the changes.

BTW, I noticed that all examples for IE functions usually set a variable ($oIE) to open a specific site or create an HTML doc. Is there a way to just pass a currently open browser window to that variable and work from there? It would save time from having to close my current browser so I can open/create a new one to log in.

I hope someone can understand my ramblings and help me out.

Link to comment
Share on other sites

  • Moderators

BTW, I noticed that all examples for IE functions usually set a variable ($oIE) to open a specific site or create an HTML doc. Is there a way to just pass a currently open browser window to that variable and work from there? It would save time from having to close my current browser so I can open/create a new one to log in.

Look at _IEAttatch

As for the form, you'd be surprised.

If you're not using Firefox browser for your manual browsing (you're missing out) but I suggest you download that and this after: https://addons.mozilla.org/en-US/firefox/addon/60

You'd be amazed at what fun things you fine in there (not to mention it saves you a ton of time). Funny using Firefox to help you code something for IE but it works :).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Yep, the Web Developer addon in Firefox is great (there are others too). I am really happy with DebugBar as an addin to IE as well - it is free for personal use and is both convenient and powerful. See my sig.

Suggest you look at _IEAttach as smoke suggests, dome some testing and then ask some more specific questions.

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

Thanks for your suggestions.

Smoke,

yes _IEAttach is much, much better than how I was doing it before. And I dont need to keep opening instances of IE :)

I have also downloaded and installed firefox but am still trying to get used to it, always have used IE on almost anything I do for webpages and just refer to friends to test a webpage on firefox. I'll give it a go once I've made progress with my current project.

Dale

I've installed DebugBar and it is so much better than having the autoit window info tool for my purpose.

I've used _IEAttach and have modified the script as follows:

#include <IE.au3>

$oIE = _IEAttach ("Webpage")
$oForm = _IEFormGetObjByName ($oIE,0)
$oUser = _IEFormElementGetObjByName ($oForm, "user")
_IEFormElementSetValue ($oUser, "****")
$oPass = _IEFormElementGetObjByName ($oForm, "pass")
_IEFormElementSetValue ($oPass, "****")
_IEFormSubmit ($oForm)
_IELoadWait ($oIE)
_IELinkClickByIndex ($oIE, 11)

Apparently I dont need the form name since I can refer to forms (and almost all obj) on a webpage via index number.

Now, am working on getting multiple usernames and passwords in there without having to use the above code multiple times on one script.

Hey, check it out, am learning something new. :)

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...