Jump to content

Recommended Posts

Posted

Hi all,

I got the need of crawling all the label tag contained within a div element, and then inspecting one by one looking for a specified content

Local $reportForm=_IEFormGetObjByName($oIE,"ui_form")

   If @error Then
      ConsoleWrite('_IEFormGetObjByName @error = ' & @error & ' @extended = ' & @extended & @CRLF)
   EndIf

   Local $divTagSites = _IEGetObjById($reportForm, "divElementId")

   If @error Then
      ConsoleWrite('_IEGetObjById for @error = ' & @error & ' @extended = ' & @extended & @CRLF)
   EndIf

  Local $divLabels = _IETagNameGetCollection($divTagSites, "label")

  If @error Then
      ConsoleWrite('_IETagNameGetCollection for label @error = ' & @error & ' @extended = ' & @extended & @CRLF)
   EndIf

   ConsoleWrite('_IETagNameGetCollection @extended = ' & @extended & @CRLF)

   For $divLabel In $divLabels
     ConsoleWrite($divLabel.for & @CRLF)
   Next

the html looks like the following

<div id="divElementId">

<td nowrap="nowrap">
<span>
<input id="divElementId_ctl01" type="checkbox" name="divElementId$ctl01" onclick="some JavaScript stuff" />
<label for="divElementId_ctl01_ctl01">ele-1000002 [1000002]</label>
</span>
</td>


</div>

what I'd like to perform is to access the label element text ele-1000002 [1000002] comparing to a variable and then check the corresponding checkbox.

What I miss is the step: accessing the text inside the label tag.

TIA.

PS: searching through the forum I found out only method based on analyzing the whole html page.

 

Posted

You can also try this:

#include <ie.au3>
#include <MsgBoxConstants.au3>

_Example()
Func _Example()
    Local $oIE = _IECreate()
    _IEDocWriteHTML($oIE,ClipGet())
    Local $oIE_ctl01 = _IEGetObjById($oIE,'divElementId_ctl01')
    If @error Then MsgBox($MB_ICONERROR, '', _
    '@error = ' & @error & @CRLF & '@extended = ' & @extended)
    MsgBox(0, '', VarGetType($oIE_ctl01))
    MsgBox(0, '', ObjName($oIE_ctl01))

    Local $oIE_label = $oIE_ctl01.nextElementSibling
    MsgBox(0, '', $oIE_label.outerhtml)
    
EndFunc

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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
×
×
  • Create New...