Jump to content

IE Automation - Clicking a Special Type of Image


Recommended Posts

All these posts about making a DarkThrone auto-recruiter made me want to try my hand at the task. So I made my own DarkThrone Recruiter. It works beautifully - except for one step. There is an image link on the login page that defies all automation attempts I can think of. The following is a load of information related to said image.

That's what it looks like. Simple enough.

Form info relating to the image button (single form):

Form Name: "" (blank)

Form Method: post

Form Action: http://www.darkthrone.com/login.dt

When that form is selected, this is the element info for the 3 elements:

Label: "" (blank), Field Name: submit, Type: hidden, Current Value: TRUE

Label: "" (blank), Field Name: email, Type: text, Current Value: [email address]

Label: "" (blank), Field Name: password, Type: password, Current Value: [password in *]

Unfortunately, _IEFormSubmit does not work on this form (tried many times already).

Under links (referring to the submit image link):

Name: Submit Query

Address: http://www.darkthrone.com/login.dt

Type: Form Submission

Target: "" (blank)

Access Key: "" (blank)

_IEClickLinkByText and _IEClickLinkByIndex don't work either, because evidently that isn't considered as a standard link in the document.

Under media (referring to the image itself):

Address: http://www.darkthrone.com/templates/notlog...tons/submit.gif

Type: Input

Alternate Text: Not Specified (none)

Count: 1

_IEClickImg doesn't work because it's not a true image - at least that's what it seems.

In the source:

<form action="/login.dt" method="post">
    <input type="hidden" name="submit" value="TRUE">
    <div class="box_border" style="width: 250px">
    <table width="100%">
      <tr>
        <td colspan="2" class="box_header">Login</td>
      </tr>
      <tr>
        <td class="box_content" width="32%">Email</td>
        <td class="box_content" width="68%"><input type="text" name="email" style="width: 100%"></td>
      </tr>
      <tr>
        <td class="box_content" width="32%">Password</td>
        <td class="box_content" width="68%"><input type="password" name="password" style="width: 100%"></td>
      </tr>
    </table>
    </div>
    <input type="image" src="templates/notloggedin/images/buttons/submit.gif" class="submitImg">
    </form>

If anyone knows how I can click this image or submit this form without using mouseclicks (as I do currently) or ControlSend/Click (since there's no control ID), please let me know.

Link to comment
Share on other sites

Feel free to try it yourself. There is no name to the form, I got it by index. There was no point in getting an object by name since I knew the index. Got all the objects I need, tried the click. Nothing. Feel free to prove me wrong though.

I think you'll find the background you need here:

Internet Explorer Automation UDF library - clicking Image Problem

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

Double-posting only so people are aware of the new post, because it is almost important (contains useful code).

I had to edit it quite a bit to work to what I needed to do. Here's the finished product:

$SubmitButtonSource = "templates/notloggedin/images/buttons/submit.gif"
$oInputs = _IETagNameGetCollection (_IEDocumentGetObj ($IEObject), "input")
For $oInput In $oInputs
    If $oInput.src <> "" And StringInStr ($oInput.src, $SubmitButtonSource, 0) Then
        $oInput.click
        ExitLoop
    EndIf
Next
Link to comment
Share on other sites

Good point - thanks for your attempt Valuater (too bad the easy way didn't work in the first place).

And sorry for the attitude I had after your reply. I respect you trying to help, it's just that I was annoyed that everything I had tried wasn't working.

Edited by greenmachine
Link to comment
Share on other sites

You could make use of javascript to do this...

send this into the adressbar:

java script:void(document.forms[0].submit())

change the 0 to whatever form it is(depending how many forms there are in the page)

Edit:

Um.. there should be no space between java and script... dunno why it puts a space there...

Edited by FreeFry
Link to comment
Share on other sites

Nice try, but that doesn't work. According to the error received, "the object does not support this property or method." Also, this is the equivalent of doing _IEFormSubmit, which I tried several times, and which failed every time. The code I posted above does work, and that's all I need.

Link to comment
Share on other sites

Oh, I didnt try it I just know it works on must other pages, where there is an form which submits data.

I think it doesnt work because of that its using css to submit the data in some way.

I'm not into html and such, i just know a little basic javascript.

Anyways, good you found something that workt =)

Link to comment
Share on other sites

Oh, I didnt try it I just know it works on must other pages, where there is an form which submits data.

I think it doesnt work because of that its using css to submit the data in some way.

I'm not into html and such, i just know a little basic javascript.

Anyways, good you found something that workt =)

Not CSS, but typically Javascript on the button used to submit -- it is very common these days instead of using the standard form submit action.

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

  • 4 weeks later...

I hope no one minds me raising this topic from the dead, but I put together greenmachines code and made a function... I don't know if this is in the new IE.au3, but if anyone wants it, it works just like _IEClickImg() ...

Func _IEFormClickImg($o_object, $s_linkText, $s_mode = "src", $i_index = 0, $f_wait = 1)
    $doc = _IEDocumentGetObj ($o_object)
    $oInputs = _IETagNameGetCollection (_IEDocumentGetObj ($o_object), "input")
    $found = 0
    $s_mode = StringLower($s_mode)
    For $oInput In $oInputs  
        Select
            Case $s_mode = "name"
                $linkText = $oInput.name
            Case $s_mode = "src"
                $linkText = $oInput.src
            Case Else
               ;; Invalid mode
                SetError(99)
                Return 0
        EndSelect
        If StringInStr($linkText, $s_linkText) Then
            if ($found = $i_index) Then
                $result = $oInput.click
                Sleep(500); Allow readystate to change before proceeding
                If ($f_wait = 1) Then _IELoadWait($o_object)
                SetError(0)
                Return 1
            EndIf
            $found = $found + 1
        EndIf
    Next
    SetError(1)
    Return 0
EndFunc

---Sparkes.

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