Modify

Opened 11 years ago

Last modified 10 hours ago

#2972 assigned Feature Request

Adding a sort of _IEAttributeGet function to IE.UDF

Reported by: j0kky Owned by: mLipok
Milestone: Component: AutoIt
Version: Severity: None
Keywords: GetAttribute IE.UDF Cc: gianlu2live@…

Description (last modified by mLipok)

There is no way to get the "class" (or other kind of) attribute value of an element using only IE Management UDF.
It can be solved just adding a simple function as:

Line 
1#include <IE.au3>
2
3_Example()
4
5Func _Example()
6 Local $oIE = _IECreate("www.autoitscript.com")
7 Local $oBody = $oIE.document.body
8 ConsoleWrite('! "Class" = ' & _IEAttributeGet($oBody, "class") & @CRLF)
9EndFunc ;==>_Example
10
11Func _IEAttributeGet($obj, $attr)
12 Return $obj.GetAttribute($attr)
13EndFunc ;==>_IEAttributeGet
14

Attachments (0)

Change History (3)

comment:1 by J-Paul Mesnage, 6 years ago

Owner: set to mLipok
Status: newassigned

comment:2 by mLipok, 11 hours ago

Description: modified (diff)

comment:3 by mLipok, 10 hours ago

Here is my proposal:

Line 
1#include <IE.au3>
2
3_Example()
4
5Func _Example()
6 Local $oIE = _IECreate("www.autoitscript.com")
7 Local $oElement = $oIE.document.body
8 ConsoleWrite('! "Class" = ' & _IEAttributeGet($oElement, "class") & @CRLF)
9EndFunc ;==>_Example
10
11Func _IEAttributeGet(ByRef $oObject, $sAttributeName)
12 If Not IsObj($oObject) Then
13 __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidDataType")
14 Return SetError($_IESTATUS_InvalidDataType, 1, 0)
15 ElseIf Not __IEIsObjType($oObject, "browserdom") Then
16 __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
17 Return SetError($_IESTATUS_InvalidObjectType, 2, 0)
18 ElseIf __IEIsObjType($oObject, "browser") Or __IEIsObjType($oObject, "document") Or __IEIsObjType($oObject, "documentcontainer") Then
19 __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
20 Return SetError($_IESTATUS_InvalidObjectType, 3, 0)
21 Else
22 Local $sAttributeValue = $oObject.GetAttribute($sAttributeName)
23 If @error Then
24 Return SetError($_IESTATUS_NoMatch, 4, 0)
25 Else
26 Return SetError($_IESTATUS_Success, 0, $sAttributeValue)
27 EndIf
28 EndIf
29EndFunc ;==>_IEAttributeGet

Modify Ticket

Action
as assigned The owner will remain mLipok.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.