Jump to content
Sign in to follow this  
Jfish

Help with IE UDF - forms automation

Recommended Posts

Jfish

I apologize for the super-newbie nature of this question.

I am trying to automate sending information to a website:

$oIE = _IECreate ("https://interactive.marylandtaxes.com/Business/VerifyExempt/User/Home.aspx")

I would like to populate one of the fields on this form and the capture the result. I am stuck on step 1 as I do not understand the examples in the manual. I am confused as to how you identify objects. I was hoping somebody could help me by using the website in this post as an example to simply send it some data "12345678." I have tried about 100 combos but can't get even the most basic functions to work. Any help would be greatly appreciated.

Thanks,

JFish


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites
DaleHohm

Suggest you download DebugBar (see my sig) for examining the web page.

Then, please run the examples for the _IEForm* functions... please don't just read the, run them. They are all fully stand-alone examples that will run and visually demonstrate the concepts.

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

Share this post


Link to post
Share on other sites
aslani

I can show you how to do the dirty work.

1) Get the source code of the page.

Example: Using Internet Explorer; Click View -> Source

This will open a Notepad with the source code of the page.

2) Identify the label of the input field.

Example: Using the web page you provided, if you want to type something in "Maryland Sales And Use Tax Number", then use that label to search the source code. When you locate that label, you'll find the <input> code after it. For this instance, this is what we've found.

<input name="txtSUT" type="text" maxlength="8" id="txtSUT" style="width:100px;" />

3) Now take note of the "name" used for this input. In this case, it's "txtSUT".

4) Now to populate the field, simply use _IEFormGetObjByName() and _IEFormElementGetObjByName() UDFs to get the <input> as object

5) You can then use _IEFormElementSetValue() to give that <input> field a value.

Here's the codes you can use.

#include <IE.au3>
$oIE = _IECreate ("https://interactive.marylandtaxes.com/Business/VerifyExempt/User/Home.aspx")
$oForm = _IEFormGetObjByName ($oIE, "frmHome")
$oQuery1 = _IEFormElementGetObjByName ($oForm, "txtSUT") ; fills out Maryland Sales And Use Tax Number
$oQuery2 = _IEFormElementGetObjByName ($oForm, "txtECN") ; fills out Exemption Certificate Number (For A Non-Profit Organization)
_IEFormElementSetValue ($oQuery1, "123456789")
_IEFormElementSetValue ($oQuery2, "AaBbCcDdEe")
;_IEFormSubmit ($oForm) ; uncomment if you want to submit the form

As for the "capturing the result"...not really sure what you meant.


[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Share this post


Link to post
Share on other sites
Jfish

I really appreciate this response. It helps a lot. Thank you. I had located the input field but did not know how to "to get the <input> as object." Also, I now see how you found the form name (I did not know to search on that and could not tell where the examples where getting the info from). What I meant by "capture the result" is this: Once you sumbit the form you will get a response that the number is either valid or invalid. First, you see a message box and then the HTML also changes to reflect the answer. Which UDF would you recommend to scrape that result?

Thanks again for the help. I am doing pretty well teaching myself other aspects of AutoIt but the whole HTML/IE is completely new to me and I am lost.

I can show you how to do the dirty work.

1) Get the source code of the page.

Example: Using Internet Explorer; Click View -> Source

This will open a Notepad with the source code of the page.

2) Identify the label of the input field.

Example: Using the web page you provided, if you want to type something in "Maryland Sales And Use Tax Number", then use that label to search the source code. When you locate that label, you'll find the <input> code after it. For this instance, this is what we've found.

<input name="txtSUT" type="text" maxlength="8" id="txtSUT" style="width:100px;" />

3) Now take note of the "name" used for this input. In this case, it's "txtSUT".

4) Now to populate the field, simply use _IEFormGetObjByName() and _IEFormElementGetObjByName() UDFs to get the <input> as object

5) You can then use _IEFormElementSetValue() to give that <input> field a value.

Here's the codes you can use.

#include <IE.au3>
$oIE = _IECreate ("https://interactive.marylandtaxes.com/Business/VerifyExempt/User/Home.aspx")
$oForm = _IEFormGetObjByName ($oIE, "frmHome")
$oQuery1 = _IEFormElementGetObjByName ($oForm, "txtSUT") ; fills out Maryland Sales And Use Tax Number
$oQuery2 = _IEFormElementGetObjByName ($oForm, "txtECN") ; fills out Exemption Certificate Number (For A Non-Profit Organization)
_IEFormElementSetValue ($oQuery1, "123456789")
_IEFormElementSetValue ($oQuery2, "AaBbCcDdEe")
;_IEFormSubmit ($oForm) ; uncomment if you want to submit the form

As for the "capturing the result"...not really sure what you meant.


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites
aslani

You have got to work this out on your own private time, unfortunately, because in order that I can help you on this is to disclose an existing private and confidential "Tax Number" which I rather not know. Because without using these numbers, there's no way I'll know what you're talking about.

Thus, this is as far as I can help you without getting both of us into trouble.

Good luck.


[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Share this post


Link to post
Share on other sites
Jfish

There is no confidential information. All you have to do is run this code to see what I mean (I tried the submit method you had in your response. It did not work so I tried this instead):

$button = _IEFormElementGetObjByName($oForm,"btnCheckStatus")

sleep(1500)

_IEAction($button,"click")

The complete code is:

#include <IE.au3>

$oIE = _IECreate ("https://interactive.marylandtaxes.com/Business/VerifyExempt/User/Home.aspx")

$oForm = _IEFormGetObjByName ($oIE, "frmHome")

$oQuery1 = _IEFormElementGetObjByName ($oForm, "txtSUT") ; fills out Maryland Sales And Use Tax Number

_IEFormElementSetValue ($oQuery1, "12345678")

$button = _IEFormElementGetObjByName($oForm,"btnCheckStatus")

sleep(1500)

_IEAction($button,"click")

If you run the code you will see the result of the search (which says 12345678) is not a valid number. That is the message that I am trying to capture. I may be able to work it out on my own, I was just looking for you to point me to the best UDF. Let me know if you can help...

Thanks again,

JFish


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites
aslani

Sorry, but I'm a little suspiscious on what you want to accomplish since it seems to me, you want to run a program to guess all posible combination of Tax Number.

I was under the impression that you already have a database of these numbers and just want to auto-fill-in the field to access informations, so you don't have to type them in one by one.

But since it looks to me you want to guess the numbers, I'm sorry, I will not help you.

Edited by aslani

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Share this post


Link to post
Share on other sites
Jfish

I am a partner is a national tax accounting firm trying to build a tool to automate the validation of client certificates associated with tax automation projects. My biography is at: http://www.ryanco.com/about-ryan/bio_fishmanj.aspx if you send me an email to jayme.fishman@ryanco.com you can validate my email address and bio. Still suspicous?

There is no confidential information. All you have to do is run this code to see what I mean (I tried the submit method you had in your response. It did not work so I tried this instead):

$button = _IEFormElementGetObjByName($oForm,"btnCheckStatus")

sleep(1500)

_IEAction($button,"click")

The complete code is:

#include <IE.au3>

$oIE = _IECreate ("https://interactive.marylandtaxes.com/Business/VerifyExempt/User/Home.aspx")

$oForm = _IEFormGetObjByName ($oIE, "frmHome")

$oQuery1 = _IEFormElementGetObjByName ($oForm, "txtSUT") ; fills out Maryland Sales And Use Tax Number

_IEFormElementSetValue ($oQuery1, "12345678")

$button = _IEFormElementGetObjByName($oForm,"btnCheckStatus")

sleep(1500)

_IEAction($button,"click")

If you run the code you will see the result of the search (which says 12345678) is not a valid number. That is the message that I am trying to capture. I may be able to work it out on my own, I was just looking for you to point me to the best UDF. Let me know if you can help...

Thanks again,

JFish


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites
Jfish

I downloaded the tool and will check it out ... looks very powerful. Thanks for the tip.

Suggest you download DebugBar (see my sig) for examining the web page.

Then, please run the examples for the _IEForm* functions... please don't just read the, run them. They are all fully stand-alone examples that will run and visually demonstrate the concepts.

Dale


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites
Jfish

okay, I have downloaded and run DebugBar. This looks like a great tool so thanks again for the recommendation. I have also run many, if not all, of the _IE help scripts. Now I am stuck again. I need to figure out how to reference a specific part of my form as an object to capture its text (if this is not the best way, please let me know). Debugbar tells me that it is the same form "frmHome" and that within the form there is a table, a body in that table, and a section with a tag called <TD> which contains the information that I am looking for. I am trying to figure out what the name of the variable is that I need to reference as an object to get this information. The entire section appears below (I will highlight what I am after in red). Any help you could offer would be greatly appreciated:

<FORM language=javascript id=frmHome name=frmHome onsubmit="if (!Validatoronsubmit()) return false;" action=Home.aspx method=post autocomplete="off"><INPUT type=hidden value=dDwtMTI0NjE4MjE5Mjs7Ph191lT1SShxXGkYzaXnAhpTrBHj name=__VIEWSTATE>

<script language=Javascript>

var ScrollToFirstTime = true;

var ScrollToOldonfocus = window.onfocus;

function ScrollTo(){

if(ScrollToFirstTime) window.scrollTo(300,130);

ScrollToFirstTime = false;

if(ScrollToOldonfocus) ScrollToOldonfocus();

}

window.onfocus = ScrollTo;

</SCRIPT>

<script language=Javascript> var AlertFirstTime = true;var AlertOldonfocus = window.onfocus; function Alertonfocus() { var tempAlertFirstTime = AlertFirstTime; AlertFirstTime = false; if(tempAlertFirstTime) alert('The Registration number you have entered: 12851076 is NOT valid for the issuance of resale certificates.\n\nFor additional information, please contact Taxpayer Service by telephone at (410) 767-1300 in the Baltimore area or at 1-800-492-1751 from elsewhere in Maryland or by email at sut@comp.state.md.us');if(AlertOldonfocus && tempAlertFirstTime) AlertOldonfocus(); } window.onfocus = Alertonfocus; </SCRIPT>

<script language=javascript src="/aspnet_client/system_web/1_1_4322/WebUIValidation.js" type=text/javascript></SCRIPT>

<TABLE>

<TBODY>

<TR>

<TD class=appMsg width="100%">The Registration number you have entered:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>12851076 </B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;is NOT valid for the issuance of resale certificates.

<P>For additional information, please contact Taxpayer Service by telephone at (410) 767-1300 in the Baltimore area or at 1-800-492-1751 from elsewhere in Maryland or by email at sut@comp.state.md.us </P></TD></TR></TBODY></TABLE><BR>

Thanks,

JFish

I apologize for the super-newbie nature of this question.

I am trying to automate sending information to a website:

$oIE = _IECreate ("https://interactive.marylandtaxes.com/Business/VerifyExempt/User/Home.aspx")

I would like to populate one of the fields on this form and the capture the result. I am stuck on step 1 as I do not understand the examples in the manual. I am confused as to how you identify objects. I was hoping somebody could help me by using the website in this post as an example to simply send it some data "12345678." I have tried about 100 combos but can't get even the most basic functions to work. Any help would be greatly appreciated.

Thanks,

JFish


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites
PsaltyDS

Try this:

$oForm = _IEFormGetObjByName($oIE, "frmHome")
$oTD = _IETagNameGetCollection($oForm, "TD", 0); Get first TD tag
$sInnerText = _IEPropertyGet($oTD, "innertext")
MsgBox(64, "Text", "Text found: " & $sInnerText)

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Jfish

That worked! I really appreciate the help. I don't know that I could have solved that. I can see all the information, I am just not experienced enough with these functions to know how to reference what I am after. Along those lines, I have a question, I assume that if it was the second <TD> tag that I was after (if there was one) I would set the last argument to "2" as in: _IETagNameGetCollection($oForm, "TD", 2). Is that accurate?

Try this:

$oForm = _IEFormGetObjByName($oIE, "frmHome")
$oTD = _IETagNameGetCollection($oForm, "TD", 0); Get first TD tag
$sInnerText = _IEPropertyGet($oTD, "innertext")
MsgBox(64, "Text", "Text found: " & $sInnerText)

:)


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites
PsaltyDS

That worked! I really appreciate the help. I don't know that I could have solved that. I can see all the information, I am just not experienced enough with these functions to know how to reference what I am after. Along those lines, I have a question, I assume that if it was the second <TD> tag that I was after (if there was one) I would set the last argument to "2" as in: _IETagNameGetCollection($oForm, "TD", 2). Is that accurate?

No, the index is 0-based, so 0 was the first one, and 2 is the third one. If you don't know which index you want, use -1 (the default) and you get a collection object containing ALL of them. Then you can loop through the collection and use some other test to pick the one you want.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Jfish

Thanks again!

No, the index is 0-based, so 0 was the first one, and 2 is the third one. If you don't know which index you want, use -1 (the default) and you get a collection object containing ALL of them. Then you can loop through the collection and use some other test to pick the one you want.

:)


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
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
Sign in to follow this  

×