Sign in to follow this  
Followers 0
SteveP

Detect if HTML element exists

3 posts in this topic

I am trying to detect when "tdResult" exists in a web page. This indicates to me that the process is finished and I can close the browser. Here is the snippet of HTML source code from the web page in question:

<tr class="Inquiry_Body">
    <td id="tdResults" style="DISPLAY:none">
    </td>
</tr>

and here is my code:

#include <IE.au3>

;Load web page
$oIE = _IECreate ("http://logostrain/Logos/FM/ThirdPartyProcesses/ThirdPartyProcessMaint.aspx")
_IELoadWait ($oIE)

;Import stuff
$oForm = _IEFormGetObjByName ($oIE, "Form1")
$oSelect = _IEFormElementGetObjByName ($oForm, "ddlProcess")
_IEFormElementOptionselect ($oSelect, "BSA", 1, "byText")
$oSubmit = _IEGetObjByName ($oIE, "bpButtonPanel$CImport")
_IEAction ($oSubmit, "click")

;Wait unitl tdResults can be detected
While 1
    $oDiv = _IEGetObjById ($oIE, "tdResults")
    If @error = 0 Then
        _IEQuit ($oIE)
        Exit
    EndIf
    Sleep(5000)
WEnd

Any suggestions would be helpful.

Share this post


Link to post
Share on other sites



While NOT IsObj(_IEGetObjById ($oIE, "tdResults"))
Sleep(5000)
WEnd

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

While NOT IsObj(_IEGetObjById ($oIE, "tdResults"))
Sleep(5000)
WEnd
weaponx,

Thanks for the quick response but it looks like I was wrong about the "tdResults" as a flag the process is done. It looks like the only way to tell for sure is to look for when the words "records imported" show up in the body of the page. This what I came up with which actually seems to work:

$sText = _IEBodyReadText ($oIE)
While 1
    If StringRegExp($sText,"records imported",0) = 1 Then
        _IEQuit($oIE)
        Exit
    EndIf
    Sleep(5000)
    $sText = _IEBodyReadText ($oIE)
WEnd
Edited by SteveP

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  
Followers 0