Sign in to follow this  
Followers 0
MacBain00

_IEDocReadHTML Help?

11 posts in this topic

#1 ·  Posted (edited)

I'm searching for a specific string "Unscheduled" which I'm having no trouble with. The problem is once I find the string, I need to click the link that is associated with "Unscheduled" which is on the next line of HTML code. How do I keep reading the HTML document from the point that it finds the string I'm looking for?

Edit: Thought I would throw in the logic for the code:

Find first "Unscheduled" and click "Generate Now" link. Sleep 5 minutes. If "In Progress" Sleep, Else "Find Next Unscheduled" and click "Generate Now" until "Unscheduled" does not exist.

My Code:

$sText1 = _IEDocReadHTML($Frametype)
$avFeature = _StringBetween($sText1, '_StatusValue>', '</SPAN>')
For $i = 0 to UBound($avFeature)-1
    If StringInStr($avFeature[$i], $matchstring) Then
        $match = 1
        MsgBox(0, "", $avFeature[$i])
    EndIf
    Next
    If $match = 0 Then
        MsgBox(0, "", "nothing found")
    EndIf

From HTML Code...if you scroll about halfway down you'll see..."ctl10_StatusValue>Unscheduled</SPAN>" I need the next line: "<TD><INPUT id=Results__ctl10_imgGenerateNow title="Generate Now" onclick="if (!confirm('PDF file generation can be taxing on server resources, and should only be performed during times of low server activity. Proceed?')) return false;" type=image alt="" src="../../Img/library_copy_from.gif" border=0

name=Results:_ctl10:imgGenerateNow> </TD>"

<TR class=evenRow nowrap="nowrap">
<TD><INPUT id=Results__ctl9_Select onclick=DetermineSelectDivVisible(this.checked); type=checkbox name=Results:_ctl9:Select> </TD>
<TD><IMG id=Results__ctl9_FileRequestTypeImg title="Data PDF" alt="" src="/(tiqqc52c44oy3p45shtyn145)/Img/i_pdf_data.gif" border=0> </TD>
<TD><SPAN id=Results__ctl9_NameLabel title="A714_20050193 (Clinical Views)">193001084_15 JAN 1987</SPAN> </TD>
<TD></TD>
<TD>Full Data - Default </TD>
<TD>Stephen Sorrells </TD>
<TD><SPAN id=Results__ctl9_CreatedLabel>13 Aug 2007 16:38:48</SPAN> </TD>
<TD>13 Aug 2007 16:39:01 </TD>
<TD><SPAN id=Results__ctl9_StatusValue onmouseover="this.style.cursor='pointer'" title="Object reference not set to an instance of an object." onclick="var 
stackTrace = document.getElementById('Results__ctl9_StackTrace'); if (stackTrace.style.display == 'none') stackTrace.style.display='block'; else 
stackTrace.style.display='none';">Execution error</SPAN></TD>
<TD><INPUT id=Results__ctl9_imgEdit title=Edit type=image alt="" src="../../Img/i_cedit.gif" border=0 name=Results:_ctl9:imgEdit> </TD>
<TD><INPUT id=Results__ctl9_imgGenerateNow title="Generate Now" onclick="if (!confirm('PDF file generation can be taxing on server resources, and should only be performed during times of low server activity. Proceed?')) return false;" type=image alt="" src="../../Img/library_copy_from.gif" border=0 
name=Results:_ctl9:imgGenerateNow> </TD>
<TD><INPUT id=Results__ctl9_imgCopy title=Clone type=image alt="" src="../../Img/i_copy.gif" border=0 name=Results:_ctl9:imgCopy> </TD>
<TD><INPUT id=Results__ctl9_Delete title=Delete onclick="if (!confirm('You are about to delete an existing PDF file request. Proceed?')) return false;" 
type=image alt="" src="../../Img/i_ccancel.gif" border=0 name=Results:_ctl9:Delete> </TD></TR>
<TR class=oddRow nowrap="nowrap">
<TD><INPUT id=Results__ctl10_Select onclick=DetermineSelectDivVisible(this.checked); type=checkbox name=Results:_ctl10:Select> </TD>
<TD><IMG id=Results__ctl10_FileRequestTypeImg title="Data PDF" alt="" src="/(tiqqc52c44oy3p45shtyn145)/Img/i_pdf_data.gif" border=0> </TD>
<TD><SPAN id=Results__ctl10_NameLabel title="A000_92005278 (Clinical Views)">Amit_Test1</SPAN> </TD>
<TD></TD>
<TD>Full Data - Default </TD>
<TD>Amit Patel </TD>
<TD><SPAN id=Results__ctl10_CreatedLabel>13 Aug 2007 17:44:18</SPAN> </TD>
<TD></TD>
<TD><SPAN id=Results__ctl10_StatusValue>Unscheduled</SPAN> </TD>
<TD><INPUT id=Results__ctl10_imgEdit title=Edit type=image alt="" src="../../Img/i_cedit.gif" border=0 name=Results:_ctl10:imgEdit> </TD>
<TD><INPUT id=Results__ctl10_imgGenerateNow title="Generate Now" onclick="if (!confirm('PDF file generation can be taxing on server resources, and should only be performed during times of low server activity. Proceed?')) return false;" type=image alt="" src="../../Img/library_copy_from.gif" border=0 
name=Results:_ctl10:imgGenerateNow> </TD>
<TD><INPUT id=Results__ctl10_imgCopy title=Clone type=image alt="" src="../../Img/i_copy.gif" border=0 name=Results:_ctl10:imgCopy> </TD>
<TD><INPUT id=Results__ctl10_Delete title=Delete onclick="if (!confirm('You are about to delete an existing PDF file request. Proceed?')) return false;" 
type=image alt="" src="../../Img/i_ccancel.gif" border=0 name=Results:_ctl10:Delete> </TD></TR>

Any help would greatly be appreciated. If you need more information or I need to be more specific, please tell me. =)

Edited by MacBain00

-Work Smarter, Not Harder, Use More AutoIT

Share this post


Link to post
Share on other sites



There would be lots of different ways to do this that you might want to adjust based on more details of the page and how it changes from visit to visit and how you need to reach to those changes.

Most important change in approach however is to walk through the page using the document structure rather than looking at the source of the whole page at once.

Making some assumptions: 1) the first table on the page (index 0) has the data you want 2) the $matchstring you want is "Unscheduled" and 3) the button you want to click is always in the same table row as the "Unscheduled" label and it always has an ID of Results__ctl10_imgGenerateNow

If any of these are invalid assumptions you'll need to adjust.

This will start with a table, look through each row for HTML that matches "StatusValue>Unscheduled", then finds the object in the same row with ID=Results__ctl10_imgGenerateNow and clicks it...

$oTable = _IETableGetCollection($Frametype, 0)
$oTRs = _IETagNameGetCollection($oTable, "tr")
For $oTR in $oTRs
    If StringInStr(_IEPropertyGet($oTR, "innerHTML", "StatusValue>Unscheduled") Then
        $oInput = _IEGetObjByID($oTR, "Results__ctl10_imgGenerateNow")
        _IEAction($oInput, "click")
        ExitLoop
    EndIf
Next

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

OMG. Surprisingly easier than I thought. I'll still have to play with it because assumption 3 is incorrect adn the CTL10 will change to CTL# for each row and will be unique each time. Also assumption 1 is wrong, but that isn't a big deal since it's just index 4. But other than that, awesome explaination. I'll play with it a little bit later today, but all the help these forums give is always appreciated. :)


-Work Smarter, Not Harder, Use More AutoIT

Share this post


Link to post
Share on other sites

I'm having a bit of trouble with the following line. If I'm correct, then StringInStr should have a main value with the comparison value.

If StringInStr(_IEPropertyGet($oTR, "innerHTML", "StatusValue>Unscheduled") Then

so should this really be:

If StringInStr(_IEPropertyGet($oTR, "innerHTML", "StatusValue>Unscheduled"),"Unscheduled") Then ???


-Work Smarter, Not Harder, Use More AutoIT

Share this post


Link to post
Share on other sites

Unfortunately that's not the only problem...I'm having trouble capturing any data for the table. When I do a Msgbox to see what the specific $otr has, it just is blank and does not find a match. =(

Again any help is appreciated.


-Work Smarter, Not Harder, Use More AutoIT

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Unfortunately that's not the only problem...I'm having trouble capturing any data for the table. When I do a Msgbox to see what the specific $otr has, it just is blank and does not find a match. =(

Again any help is appreciated.

The variable $oTR is an object and won't display in a MsgBox. If you want to see the text in it you need to use a method like:

$sTR = $oTR.InnerText
MsgBox(64, "Text", $sTR)

:)

Edited by PsaltyDS

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

If StringInStr(_IEPropertyGet($oTR, "innerHTML", "StatusValue>Unscheduled") Then

Sorry, missing ")". Regarding looking at the contents of the TR, make certain you examing innerHTML or innerText -- $oTR is an object variable, not the content itself.

$oTable = _IETableGetCollection($Frametype, 0)
$oTRs = _IETagNameGetCollection($oTable, "tr")
For $oTR in $oTRs
    If StringInStr(_IEPropertyGet($oTR, "innerHTML"), "StatusValue>Unscheduled") Then
        $oInput = _IEGetObjByID($oTR, "Results__ctl10_imgGenerateNow")
        _IEAction($oInput, "click")
        ExitLoop
    EndIf
Next

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

I'm still working on it as it's still not matching, but I have one last question.

Results__ctl10_StatusValue

That value....ctl aways changes. Is there a way to make it so it just ignores that? liek ctl## or something that just puts in any character?


-Work Smarter, Not Harder, Use More AutoIT

Share this post


Link to post
Share on other sites

I assume you mean Results__ctl10_imgGenerateNow? Perhaps something like this:

$oTable = _IETableGetCollection($Frametype, 0)
$oTRs = _IETagNameGetCollection($oTable, "tr")
For $oTR in $oTRs
    If StringInStr(_IEPropertyGet($oTR, "innerHTML"), "StatusValue>Unscheduled") Then
        $oElements = _IETagNameGetCollection($oTR, "input")
        For $oElement in $oElements
            If StringInStr($oElement.id, "_imgGenerateNow") Then
                _IEAction($oElement, "click")
                ExitLoop
            EndIf
        Next
    EndIf
Next

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

Thanks again Dale. I have my code 99% done. I'm stuck on one last part.

When you click on the _imgGenerateNow a windows popups up asking you to confirm or cancel. Now the problem is, I've used a ControlClick as a script by itself and it works perfectly. The problem is when I use it within my code. When that confirmation window pops up, it freezes the script and waits for me to manual click ok.

Func _FindUnscheduled()
    $oIE = _IEAttach("Medidata Rave")
    $Frametype = _IEFrameGetObjByName($oIE,"main")
    $oTable = _IETableGetCollection($Frametype, 13)
    $oTRs = _IETagNameGetCollection($oTable, "tr")
    For $oTR in $oTRs
        If StringInStr(_IEPropertyGet($oTR, "innerHTML"), "StatusValue>Unscheduled") Then
            $test = "match"
            $oElements = _IETagNameGetCollection($oTR, "input")
            For $oElement in $oElements
                If StringInStr($oElement.id, "_imgGenerateNow") Then
                    _IEAction($oElement, "click")
                ;script freezes here and does not go to next line
                    ControlClick("Windows Internet Explorer", "", "[CLASS:Button; TEXT:OK]")
                    ExitLoop
                EndIf
            Next
            ExitLoop
        EndIf
    Next
    If $test = "match" Then
        $match = 0
        $test = ""
    Else
        $match = 1
    EndIf
EndFunc

Again, Any help would be appreciated.


-Work Smarter, Not Harder, Use More AutoIT

Share this post


Link to post
Share on other sites

Take a look at the helpfile for _IEAction in the beta 3.2.5.4 or higher. Example 2 shows you how to avoid this.

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

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