Jump to content

Help: Internet Explorer Automation Udf Library


Recommended Posts

Moving my post here, as per DaleHohm

I'm having trouble trying to use IE.au3 to interact with www.vtext.com. I'm not an expert with this stuff, but I been reading the examples here, and trying to piece together my script. So far it does 95% of what I want it to do for now.

I used the following script to get the form names and types:

#include <IE.au3>

$oIE = _IECreate()
_IENavigate($oIE, "www.vtext.com")
$oDoc = _IEDocumentGetObj($oIE)

$forms = _IEFormGetCollection($oDoc)
For $form in $forms
    ConsoleWrite("Form name: " & $form.name & @CR)
    $fes = _IEFormElementGetCollection($form)
    For $fe in $fes
        ConsoleWrite(@Tab & $fe.name & @TAB & "Type: " & $fe.type & @CR)
    Next
Next

here is the main part of the script I am using, it's from the hotmail example and uses the values returned from the above code (l left out all my failing attempts to get it to hit the 'ok' button, that would follow _IEFormSubmit($o_form) in the script) :

#include <IE.au3>
$oIE = _IECreate()
_IENavigate($oIE, "www.vtext.com")

$o_form = _IEFormGetObjByName($oIE, "message_form")
;------------------------------------------------------------------------------------
$o_textarea1 = _IEFormElementGetObjByName($o_form, "min");      <----Send To
$o_textarea2 = _IEFormElementGetObjByName($o_form, "text");     <----Message
$o_text1 = _IEFormElementGetObjByName($o_form, "subject");      <----From
;$o_text2 = _IEFormElementGetObjByName($o_form, "sender");      <----Reply To Address

; Set field values and submit the form
;------------------------------------------------------------------------------------
_IEFormElementSetValue($o_textarea1, "5551234567")
_IEFormElementSetValue($o_textarea2, "This is a test")
_IEFormElementSetValue($o_text1, "AutoIt")
;_IEFormElementSetValue($o_text2, "sender")

_IEFormSubmit($o_form)
Exit

But the problem is after the submit, it opens up a new page (same url) for a conformation 'ok' for it to send the text message. And I can't find any way to interact with this 'ok' button (without using autoit mouse click coords). I've tried combing the 2 scripts above so it will return the form values, then use the second script to send text to the fields in the form, and then sleep for about 10 seconds (to wait for the form to submit and load the next page) and then tried to use the first script to reread all the form values again while it is on the new page. It returns the same values, but they are now type:hidden.

The source code doesn't seem to show anything useful, at least to me. I know it is doing stuff in java by looking at the source code of the page. Does anyone have any ideas on how to execute the 'ok' button on the conformation page? (i know the filename of the button is btn_ok.gif - but i guess that doesn't really help).

Link to comment
Share on other sites

Does it react the same way with the script as when you perform the steps interactively?

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'm not sure what you mean. Everything in the script I posted works, my problem is that after the script submits (_IEFormSubmit), a new page is displayed (but it is the same url). On this new page there is a conformation button, but I don't really know what kind of a button it is or if it is really a button. But it requires me to click it, to confirm the text message to be sent.You can run the above script as it is, and you will see what I mean, a new page will be displayed in the current browser.

I was playing with the IE-Builder 1.0.4 thing just now, and in the source for the page it displays something that I think could be this button, but I can't get it to do anything to it. This is how I found the name "disclaimer_submit", but I am not really sure it belongs to what I am trying to click (but I think it does, since i can't find anything else that seems like it would be it).

Here is what the page looks like:

Posted Image

Here is the info from IE-Builder 1.0.4 that I think belongs to those 2 buttons:

Posted Image

Basically I need the stuff for page 2 to work, below are all the thigns I've been trying to interact with this button:

#include <IE.au3>
$oIE = _IECreate()
_IENavigate($oIE, "www.vtext.com")

$o_form = _IEFormGetObjByName($oIE, "message_form")
;------------------------------------------------------------------------------------
$o_textarea1 = _IEFormElementGetObjByName($o_form, "min");      <----Send To
$o_textarea2 = _IEFormElementGetObjByName($o_form, "text");     <----Message
$o_text1 = _IEFormElementGetObjByName($o_form, "subject");      <----From

; Set field values and submit the form
;------------------------------------------------------------------------------------
_IEFormElementSetValue($o_textarea1, "5551234567")
_IEFormElementSetValue($o_textarea2, "This is a test")
_IEFormElementSetValue($o_text1, "AutoIt")

_IEFormSubmit($o_form)
;--------------------------------------------------------------------------------------
;-----------page 2-------------------------------------------------------------------
;--------------------------------------------------------------------------------------
Sleep(5000);<--- can change this to a lower value later on;)
;--------------------------------------------------------------------------------------
$o_form2 = _IEFormGetObjByName($oIE, "message_form")
$o_image1 = _IEFormElementGetObjByName($o_form, "disclaimer_submit");       <----Submit Button
;$o_image1 = _IEFormElementGetObjByIndex($o_form2,318)
;$o_image1 = _IEFormGetNameByIndex($o_form2,318)
;$o_image1 = _IEFormGetObjByIndex($o_form2,318)


$o_image1.click
;$o_image1.focus()
;Send("{Enter}")
;_IEClickImg($o_image1, "disclaimer_submit")


_IELoadWait($oIE)
Exit
Edited by Diverge
Link to comment
Share on other sites

Ah, I see... that button is a problem for the DOM - it is an INPUT TYPE=IMAGE

see here for a solution

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

Okay, I tried using the example you referenced to me, and I came up with the following (I had to move the 'Then' to the end of the line of the 'If' statement or it gave me an error):

#include <IE.au3>
$oIE = _IECreate()
_IENavigate($oIE, "www.vtext.com")

$o_form = _IEFormGetObjByName($oIE, "message_form")
;------------------------------------------------------------------------------------
$o_textarea1 = _IEFormElementGetObjByName($o_form, "min");      <----Send To
$o_textarea2 = _IEFormElementGetObjByName($o_form, "text");     <----Message
$o_text1 = _IEFormElementGetObjByName($o_form, "subject");      <----From

; Set field values and submit the form
;------------------------------------------------------------------------------------
_IEFormElementSetValue($o_textarea1, "5551234567")
_IEFormElementSetValue($o_textarea2, "This is a test")
_IEFormElementSetValue($o_text1, "AutoIt")

_IEFormSubmit($o_form)
;--------------------------------------------------------------------------------------
;-----------page 2---------------------------------------------------------------------
;--------------------------------------------------------------------------------------
Sleep(5000)
;--------------------------------------------------------------------------------------
$src = "../images/buttons/btn_ok.gif"
$oInputs = _IETagNameGetCollection($oIE, "input")
For $oInput in $oInputs
    MsgBox("","","in loop")                 ;<---- added this for debugging
    If $oInput.src = $src Then
         MsgBox("","","Found Match");<---- added this for debugging
         $oInput.click
         ExitLoop
    EndIf
Next

Exit
I get the following consule error:

+>AU3Check ended.rc:0
>Running:(3.1.1.117):C:\Program Files\AutoIt3\beta\autoit3.exe "C:\Documents and Settings\Lou\Desktop\AutoIt_Scripts\Verizon_Vtext_v2.au3"  
C:\Program Files\AutoIt3\beta\Include\IE.au3 (1190) : ==> The requested action with this object has failed.: 
Return $o_object.GetElementsByTagName ($s_TagName) 
Return $o_object.GetElementsByTagName ($s_TagName)^ ERROR
+>AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 6.764
Here is the line from the source code of page to that I believe is reference to the so called weird button:

<input type="image" name="disclaimer_submit" src="../images/buttons/btn_ok.gif" border="0">
I tried setting $src="btn_ok.gif" too, and got the same error.Am I doing something wrong?

Edit: I added MsgBox's for debugging purposes (in the code you last referenced to me). It seems the it never finds a match, because it never enters the loop; it must find an error in this line: $oInputs = _IETagNameGetCollection($oIE, "input")

Edited by Diverge
Link to comment
Share on other sites

Sorry, there was a problem with the example.

_IETagNameGetCollection requires a document object.

Here you go:

$src = "https://www.vtext.com/customer_site/images/buttons/btn_ok.gif"
$oInputs = _IETagNameGetCollection($oIE.document, "input")
For $oInput in $oInputs
    If $oInput.type = "image" and $oInput.src = $src Then
         $oInput.click
         ExitLoop
    EndIf
Next

Edit: note, I have also fixed the example in the other location.

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