Jump to content

Another iFrame and element question


Recommended Posts

Hello,
I'm trying to set the value of an input value in an iframe which is a cross reference.

Here is my code:

$oFrame = _IEFrameGetObjByName($oIE, "AID_1460048722447_iframe")
If @error Then
    ConsoleWrite("Cannot get this frame" & @CRLF)
EndIf
If Not IsObj($oFrame) Then
    ConsoleWrite("Frame was not found" & @CRLF)
EndIf

;try each item one by one
$o1 = _IEGetObjById($oFrame, "serviceNo_input_value")
$o2 = _IEGetObjByName($oFrame, "searchCond.serviceNo")
$o3 = _IEFrameGetObjByName($oFrame, "searchCond.serviceNo")
$o4 = _IEFormGetObjByName($oFrame, "searchCond.serviceNo")
$o5 = _IEFormElementGetObjByName($oFrame, "searchCond.serviceNo")

This is the output for each $o1 to $o5 trying:

;result for $o1
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
"C:\Program Files\AutoIt3\Include\IE.au3" (1899) : ==> The requested action with this object has failed.:
If IsObj($oObject.document.getElementById($sID)) Then
If IsObj($oObject^ ERROR
->00:08:17 AutoIt3.exe ended.rc:1
+>00:08:17 AutoIt3Wrapper Finished.

;result for $o2
"C:\Program Files\AutoIt3\Include\IE.au3" (1875) : ==> The requested action with this object has failed.:
If IsObj($oObject.document.GetElementsByName($sName).item($iIndex)) Then
If IsObj($oObject^ ERROR
->00:09:49 AutoIt3.exe ended.rc:1
+>00:09:49 AutoIt3Wrapper Finished.

;result for $o3
"C:\Program Files\AutoIt3\Include\IE.au3" (704) : ==> The requested action with this object has failed.:
$oTemp = $oObject.document.parentWindow
$oTemp = $oObject^ ERROR
->00:10:18 AutoIt3.exe ended.rc:1
+>00:10:18 AutoIt3Wrapper Finished.

;result for $o4
"C:\Program Files\AutoIt3\Include\IE.au3" (930) : ==> The requested action with this object has failed.:
Local $oCol = $oObject.document.forms.item($sName)
Local $oCol = $oObject^ ERROR
->00:10:33 AutoIt3.exe ended.rc:1
+>00:10:33 AutoIt3Wrapper Finished.

;result for $o5
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
--> IE.au3 T3.0-2 Error from function _IEFormElementGetObjByName, $_IESTATUS_InvalidObjectType
+>00:10:49 AutoIt3.exe ended.rc:0
+>00:10:49 AutoIt3Wrapper Finished.

I have also checked these posts for reference, but I'm missing something which I cannot find.

I don't know how to copy the content of this html at once, so I provided in screenshot. Is there a way that I can get this element?

Source.png

TY.

Link to comment
Share on other sites

I have tried like this:

$oFrames = _IEFrameGetCollection ($oIE)
$iNumFrames = @extended
ConsoleWrite("Total Frames: " & $iNumFrames & @CRLF)
For $i = 0 to ($iNumFrames - 1)
    $oFrame = _IEFrameGetCollection ($oIE, $i)
    ;check here for the correct iframe
    If $oFrame.name <> "" Then ;ignore the empty names
        ConsoleWrite($oFrame.name & @CRLF)
    EndIf
Next

I have a lot of empty frames, and two frames only; home frame and AID_... Output is like that:

--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
Total Frames: 142
home_iframe
"D:\Taylan\Projects\AU3\Browser\TimesMe\TimesMe.au3" (18) : ==> The requested action with this object has failed.:
If $oFrame.name <> "" Then
If $oFrame^ ERROR
->12:01:42 AutoIt3.exe ended.rc:1
+>12:01:42 AutoIt3Wrapper Finished.

This is how it looks like, I'm trying to get AID_somenumber:

 

If I use _IEFrameGetCollection I cannot find my frame in the list, it's giving the error. So, I'm thinking that I cannot really get the frame with AID_...

I can find the AID number, how can I get into it? There are some input box which I want to reach.

My Frame DOM.png

My Frame Empty Items.png

Edited by taylansan
Posting the images

TY.

Link to comment
Share on other sites

Try this script and show me the output:

 

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
$oFrames = _IEFrameGetCollection ($oIE)
$iNumFrames = @extended
ConsoleWrite("Total Frames: " & $iNumFrames & @CRLF)
For $i = 0 to ($iNumFrames - 1)
    $oFrame = _IEFrameGetCollection ($oIE, $i)
    ConsoleWrite("number"&$i&":"&$oFrame.name & @CRLF)
Next

Func MyErrFunc()
    Local $err = $oMyError.number
    If $err = 0 Then $err = -1
    $g_eventerror = $err  ; to check for after this function returns
Endfunc
Link to comment
Share on other sites

Hi Juvigy,

Here is the output. All of the frames are blank. There is one home frame:

>"C:\Program Files\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "D:\Taylan\Projects\AU3\Browser\TimesMe\TimesMe.au3" /UserParams    
+>15:21:03 Starting AutoIt3Wrapper v.16.306.1237.0 SciTE v.3.6.2.0   Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X86  Environment(Language:0409)  CodePage:0  utf8.auto.check:4    # detect ascii high characters and if none found set default encoding to UTF8 and do not add BOM
+>         SciTEDir => C:\Program Files\AutoIt3\SciTE   UserDir => C:\Users\t00722811\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\t00722811\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.2)  from:C:\Program Files\AutoIt3  input:D:\Taylan\Projects\AU3\Browser\TimesMe\TimesMe.au3
+>15:21:03 AU3Check ended.rc:0
>Running:(3.3.14.2):C:\Program Files\AutoIt3\autoit3.exe "D:\Taylan\Projects\AU3\Browser\TimesMe\TimesMe.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
Total Frames: 142
number0:
number1:
number2:
number3:
number4:
number5:
number6:
number7:
number8:
number9:
number10:
number11:
number12:
number13:
number14:
number15:
number16:
number17:
number18:
number19:
number20:
number21:
number22:
number23:
number24:
number25:
number26:
number27:
number28:
number29:
number30:
number31:
number32:
number33:
number34:
number35:
number36:
number37:
number38:
number39:
number40:
number41:
number42:
number43:
number44:
number45:
number46:
number47:
number48:
number49:
number50:
number51:
number52:
number53:
number54:
number55:
number56:
number57:
number58:
number59:
number60:
number61:
number62:
number63:
number64:
number65:
number66:
number67:
number68:
number69:
number70:
number71:
number72:
number73:
number74:
number75:
number76:
number77:
number78:
number79:
number80:
number81:
number82:
number83:
number84:
number85:
number86:
number87:
number88:
number89:
number90:
number91:
number92:
number93:
number94:
number95:
number96:
number97:
number98:
number99:
number100:
number101:
number102:
number103:
number104:
number105:
number106:
number107:
number108:
number109:
number110:
number111:
number112:
number113:
number114:
number115:
number116:
number117:
number118:
number119:
number120:
number121:
number122:
number123:
number124:
number125:
number126:
number127:
number128:
number129:
number130:
number131:
number132:
number133:
number134:
number135:
number136:
number137:
number138:
number139:
number140:home_iframe
number141:
+>15:21:06 AutoIt3.exe ended.rc:0
+>15:21:06 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 3.847

In the debugger for IE, I can see the iframe with AID_1460110786614_iframe, but it's not shown in the output. And attached the screenshot.

Thank you very much for your efforts so far.

142 Frames.png

TY.

Link to comment
Share on other sites

So you will need to get the DIV first , and then the iframe inside.

Try:

        $oArray = $oDoc.getElementsByTagName ("div")
            For $element In $oArray
                    ConsoleWrite( $element.id &@CRLF)
            Next

And look for the AID_16... id.

Link to comment
Share on other sites

Using this, gives the following error that $oDoc not defined:

$oArray = $oDoc.getElementsByTagName("div")
For $element In $oArray
    ConsoleWrite( $element.id & @CRLF)
Next 


>Running AU3Check (3.3.14.2)  from:C:\Program Files\AutoIt3  input:D:\Taylan\Projects\AU3\Browser\TimesMe\TimesMe.au3
"D:\Taylan\Projects\AU3\Browser\TimesMe\TimesMe.au3"(11,44) : warning: $oDoc: possibly used before declaration.
$oArray = $oDoc.getElementsByTagName("div")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"D:\Taylan\Projects\AU3\Browser\TimesMe\TimesMe.au3"(11,44) : error: $oDoc: undeclared global variable.
$oArray = $oDoc.getElementsByTagName("div")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\Taylan\Projects\AU3\Browser\TimesMe\TimesMe.au3 - 1 error(s), 1 warning(s)
!>17:55:41 AU3Check ended. Press F4 to jump to next error.rc:2
+>17:55:41 AutoIt3Wrapper Finished.

The doc variable is not defined, so I changed it with oIE (just for trying - don't know hot to set oDoc):

$oArray = $oIE.getElementsByTagName("div")
For $element In $oArray
    ConsoleWrite( $element.id & @CRLF)
Next


>Running:(3.3.14.2):C:\Program Files\AutoIt3\autoit3.exe "D:\Taylan\Projects\AU3\Browser\TimesMe\TimesMe.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
"D:\Taylan\Projects\AU3\Browser\TimesMe\TimesMe.au3" (11) : ==> The requested action with this object has failed.:
$oArray = $oIE.getElementsByTagName("div")
$oArray = $oIE^ ERROR
->17:58:04 AutoIt3.exe ended.rc:1
+>17:58:04 AutoIt3Wrapper Finished.

Then tried to get the "div" using normal function:

Local $oInputs = _IETagNameGetCollection($oIE, "div")
For $oInput In $oInputs
    If $oInput.id = "AID_1460110786614" Then ;to check if it's the correct div
        ConsoleWrite("Okay inside that div: " & $oInput.id & @CRLF )

        _IEAction($oInput, "focus") ;trying focus for any luck

        $oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
        $oFrames = _IEFrameGetCollection ($oInput)
        $iNumFrames = @extended
        ConsoleWrite("Total Frames: " & $iNumFrames & @CRLF)
        For $i = 0 to ($iNumFrames - 1)
            $oFrame = _IEFrameGetCollection ($oInput, $i)
            ConsoleWrite("number"&$i&":"&$oFrame.name & @CRLF)
        Next

    EndIf
Next

Func MyErrFunc()
    Local $err = $oMyError.number
    If $err = 0 Then $err = -1
    $g_eventerror = $err  ; to check for after this function returns
Endfunc



>Running:(3.3.14.2):C:\Program Files\AutoIt3\autoit3.exe "D:\Taylan\Projects\AU3\Browser\TimesMe\TimesMe.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
Okay inside that div: AID_1460110786614
Total Frames: 142
number0:
number1:
number2:
number3:
number4:
number5:
number6:
number7:
number8:
number9:
number10:
number11:
number12:
number13:
number14:
number15:
number16:
number17:
number18:
number19:
number20:
number21:
number22:
number23:
number24:
number25:
number26:
number27:
number28:
number29:
number30:
number31:
number32:
number33:
number34:
number35:
number36:
number37:
number38:
number39:
number40:
number41:
number42:
number43:
number44:
number45:
number46:
number47:
number48:
number49:
number50:
number51:
number52:
number53:
number54:
number55:
number56:
number57:
number58:
number59:
number60:
number61:
number62:
number63:
number64:
number65:
number66:
number67:
number68:
number69:
number70:
number71:
number72:
number73:
number74:
number75:
number76:
number77:
number78:
number79:
number80:
number81:
number82:
number83:
number84:
number85:
number86:
number87:
number88:
number89:
number90:
number91:
number92:
number93:
number94:
number95:
number96:
number97:
number98:
number99:
number100:
number101:
number102:
number103:
number104:
number105:
number106:
number107:
number108:
number109:
number110:
number111:
number112:
number113:
number114:
number115:
number116:
number117:
number118:
number119:
number120:
number121:
number122:
number123:
number124:
number125:
number126:
number127:
number128:
number129:
number130:
number131:
number132:
number133:
number134:
number135:
number136:
number137:
number138:
number139:
number140:home_iframe
number141:
+>18:07:36 AutoIt3.exe ended.rc:0
+>18:07:36 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 7.308

Should I get all the div one by one? div: tabpage_body > div: AID_1460110786614_body > div: AID_1460110786614 > iframe: AID_1460110786614_iframe (according to the previous screenshots)

What am I missing?

TY.

Link to comment
Share on other sites

@taylansan can we check some stuff first?

IMPORTANT: please check and recheck the ID's name, make sure they are right. Just use this code, nothing else, open the website you trying to automate, make sure there is no other instance of the IE runnnig, ok?

Try this and post the console output.

#include <IE.au3>

$oIE = _IEAttach("", "instance", 1)
ConsoleWrite("IsObj($oIE) = " & IsObj($oIE) & @CRLF)
$1_div = $oIE.document.getElementById("tabpage_body")
ConsoleWrite("IsObj($1_div) = " & IsObj($1_div) & @CRLF)
$1_frame = $oIE.document.getElementById("AID_1460048722447_iframe")
ConsoleWrite("IsObj($1_div) = " & IsObj($1_frame) & @CRLF)
$1_input = $oIE.document.getElementById("serviceNo_input_value")
ConsoleWrite("IsObj($1_input) = " & IsObj($1_input) & @CRLF)

ConsoleWrite("------------ #### ------------" & @CRLF)

$2_frame = $oIE.document.getElementById("AID_1460048722447_iframe")
ConsoleWrite("IsObj($2_frame) = " & IsObj($2_frame) & @CRLF)
$2_frame_doc = $2_frame.contentWindow.document
ConsoleWrite("IsObj($2_frame_doc) = " & IsObj($2_frame_doc) & @CRLF)
$2_input = $2_frame_doc.getElementById("serviceNo_input_value")
ConsoleWrite("IsObj($2_input) = " & IsObj($2_input) & @CRLF)

Exit

 

Link to comment
Share on other sites

I'd say give this a try and see if it spits out the data your looking for.   This will most likely needed edited to fit into your script 

#include <IE.au3> #include <MsgBoxConstants.au3> Local $oIE = _IE_Example("basic") Local $sHTML = _IEDocReadHTML($oIE) MsgBox($MB_SYSTEMMODAL, "Document Source", $sHTML) _IEQuit($oIE)

 

Link to comment
Share on other sites

I have only changed the AID_ because it always changes:

$oIE = _IEAttach("", "instance", 1)
ConsoleWrite("IsObj($oIE) = " & IsObj($oIE) & @CRLF)
$1_div = $oIE.document.getElementById("tabpage_body")
ConsoleWrite("IsObj($1_div) = " & IsObj($1_div) & @CRLF)
$1_frame = $oIE.document.getElementById("AID_1460110786614_iframe")
ConsoleWrite("IsObj($1_div) = " & IsObj($1_frame) & @CRLF)
$1_input = $oIE.document.getElementById("serviceNo_input_value")
ConsoleWrite("IsObj($1_input) = " & IsObj($1_input) & @CRLF)

ConsoleWrite("------------ #### ------------" & @CRLF)

$2_frame = $oIE.document.getElementById("AID_1460110786614_iframe")
ConsoleWrite("IsObj($2_frame) = " & IsObj($2_frame) & @CRLF)
$2_frame_doc = $2_frame.contentWindow.document
ConsoleWrite("IsObj($2_frame_doc) = " & IsObj($2_frame_doc) & @CRLF)
$2_input = $2_frame_doc.getElementById("serviceNo_input_value")
ConsoleWrite("IsObj($2_input) = " & IsObj($2_input) & @CRLF)



>Running AU3Check (3.3.14.2)  from:C:\Program Files\AutoIt3  input:D:\Taylan\Projects\AU3\Browser\TimesMe\TimesMe.au3
+>19:41:04 AU3Check ended.rc:0
>Running:(3.3.14.2):C:\Program Files\AutoIt3\autoit3.exe "D:\Taylan\Projects\AU3\Browser\TimesMe\TimesMe.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
IsObj($oIE) = 1
IsObj($1_div) = 1
IsObj($1_div) = 1
IsObj($1_input) = 0
------------ #### ------------
IsObj($2_frame) = 1
"D:\Taylan\Projects\AU3\Browser\TimesMe\TimesMe.au3" (23) : ==> The requested action with this object has failed.:
$2_frame_doc = $2_frame.contentWindow.document
$2_frame_doc = $2_frame.contentWindow^ ERROR
->19:41:05 AutoIt3.exe ended.rc:1
+>19:41:05 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 2.321

I have tried with the second way too, but the output is very big. I cannot post the output because browser crashes.

The ID is the same and okay, and there is no other internet explorer instance
Because I can see that: tabpage_body ok > AID_1460110786614_iframe ok > serviceNo_input_value not ok
And yes, I'm trying to put some value into that input box after I can get the object. Because if I can get the object from this frame, I can also get other objects in the same frame too; can set the value or reading the value will be okay

Edited by taylansan
My post didn't go, so I write again

TY.

Link to comment
Share on other sites

1 minute ago, MichaelHB said:

@markyrocks i belive he is trying to set input value/text in a form, not trying to read it. :)

Ya no doubt but at this point he's not able to get the object.   I'm was trying to get back to basics here.  If the object doesn't show up in the example I posted I doubt would even be possible to get the object.  If it was an input he should be using _ieformgetobjbyname()

Link to comment
Share on other sites

@taylansan sorry for the late reply. :)

Try this and post the output.

#include <IE.au3>

$Value = "" ; put the value between the "" you want to set. Be sure its the value of the input you want to change
            ; and its a correct type, some forms validate the value.

$oIE = _IEAttach("", "instance", 1)
If Not IsObj($oIE) Then Exit ConsoleWrite("IsObj($oIE) = " & IsObj($oIE) & @CRLF)

$Frame = $oIE.document.getElementById("AID_1460110786614_iframe")
ConsoleWrite("IsObj($Frame) = " & IsObj($Frame) & @CRLF)

$Frame_Content = $Frame.contentDocument
ConsoleWrite("IsObj($Frame_Content) = " & IsObj($Frame_Content) & @CRLF)

$Input = $Frame_Content.getElementById("serviceNo_input_value")
ConsoleWrite("IsObj($Input) = " & IsObj($Input) & @CRLF)

If IsObj($Input) Then $Input.value = $Value

Exit

 

Link to comment
Share on other sites

@MichaelHB Late reply is okay, I'm late too. Actually thank you for the reply. 

This is the output:

$Value = "" ; put the value between the "" you want to set. Be sure its the value of the input you want to change
            ; and its a correct type, some forms validate the value.

$oIE = _IEAttach("", "instance", 1)
If Not IsObj($oIE) Then Exit ConsoleWrite("IsObj($oIE) = " & IsObj($oIE) & @CRLF)

$Frame = $oIE.document.getElementById("AID_1460354248311_iframe") ;<===== Changed this only because it always changes
ConsoleWrite("IsObj($Frame) = " & IsObj($Frame) & @CRLF)

$Frame_Content = $Frame.contentDocument
ConsoleWrite("IsObj($Frame_Content) = " & IsObj($Frame_Content) & @CRLF)

$Input = $Frame_Content.getElementById("serviceNo_input_value")
ConsoleWrite("IsObj($Input) = " & IsObj($Input) & @CRLF)

If IsObj($Input) Then $Input.value = $Value

Exit



>Running:(3.3.14.2):C:\Program Files\AutoIt3\autoit3.exe "D:\Taylan\Projects\AU3\Browser\TimesMe\TimesMe.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
IsObj($Frame) = 1
"D:\Taylan\Projects\AU3\Browser\TimesMe\TimesMe.au3" (18) : ==> The requested action with this object has failed.:
$Frame_Content = $Frame.contentDocument
$Frame_Content = $Frame^ ERROR
->11:01:00 AutoIt3.exe ended.rc:1
+>11:01:00 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 0.726

I can get the frame for AID, but I cannot go inside...

I think there is way to read that iframe.

TY.

Link to comment
Share on other sites

Ok , so we have progress, there are 2 nested divs with the same ID. SO try this one:

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
$oInputs = _IETagNameGetCollection($oIE, "div")
For $oInput In $oInputs
    If StringLeft($oInput.id,4) = "AID_" Then ;to check if it's the correct div
        ConsoleWrite("Okay inside that div: " & $oInput.id & @CRLF )      
        $oInputs2 = _IETagNameGetCollection($oInput, "div")
            For $oInput2 In $oInputs2
                If $oInput2.id = $oInput.id Then ;to check if it's the correct div2
                    ConsoleWrite("Okay inside that div2: " & $oInput2.id & @CRLF )
                EndIf
            Next    
    EndIf
Next

Func MyErrFunc()
    Local $err = $oMyError.number
    If $err = 0 Then $err = -1
    $g_eventerror = $err  ; to check for after this function returns
Endfunc
Link to comment
Share on other sites

@Juvigy Here is the output

>Running:(3.3.14.2):C:\Program Files\AutoIt3\autoit3.exe "D:\Taylan\Projects\AU3\Browser\TimesMe\TimesMe.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
Okay inside that div: AID_1460354248311_title
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
Okay inside that div: AID_1460354248311_close
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
Okay inside that div: AID_1460354248311_body
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
Okay inside that div: AID_1460354248311
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
+>13:54:41 AutoIt3.exe ended.rc:0
+>13:54:41 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 1.701

There are four "Okay inside div", but cannot see any "div2"

So far I have understood the logic, but I couldn't get the reason why we check 2nd div after finding and inside the 1st div

TY.

Link to comment
Share on other sites

We want to get to the second DIV which is inside the first one. In the second DIV is the IFRAME.  This is how i see it in the code screenshot.

Try it like this:

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
$oInputs = _IETagNameGetCollection($oIE, "div")
For $oInput In $oInputs
    If StringLeft($oInput.id,4) = "AID_" Then ;to check if it's the correct div
        ConsoleWrite("Okay inside that div: " & $oInput.id & @CRLF )      
        $oInputs2 = _IETagNameGetCollection($oInput, "div")
            For $oInput2 In $oInputs2
                ConsoleWrite("Div2: " & $oInput2.id & @CRLF )
            Next    
    EndIf
Next

Func MyErrFunc()
    Local $err = $oMyError.number
    If $err = 0 Then $err = -1
    $g_eventerror = $err  ; to check for after this function returns
Endfunc

 

Link to comment
Share on other sites

Here we can get inside the second DIV

$oInputs = _IETagNameGetCollection($oIE, "div")
For $oInput In $oInputs
    If StringLeft($oInput.id,4) = "AID_" Then ;to check if it's the correct div
        ConsoleWrite("Okay inside that div: " & $oInput.id & @CRLF )
        $oInputs2 = _IETagNameGetCollection($oInput, "div")
        For $oInput2 In $oInputs2
            ConsoleWrite("Div2: " & $oInput2.id & @CRLF )
            ; <==== I have edeted here
            If $oInput2.id = "AID_1460373684268" Then
                ConsoleWrite("It's okay we found this" & @CRLF)
                $Frame = $oInput2.document.getElementById("AID_1460373684268_iframe")
                ConsoleWrite("IsObj($Frame) = " & IsObj($Frame) & @CRLF)
                $o1 = _IEGetObjById($Frame, "serviceNo_input_value")
                $o2 = _IEGetObjByName($Frame, "searchCond.serviceNo")
                $o3 = _IEFrameGetObjByName($Frame, "searchCond.serviceNo")
                $o4 = _IEFormGetObjByName($Frame, "searchCond.serviceNo")
                $o5 = _IEFormElementGetObjByName($Frame, "searchCond.serviceNo")
            EndIf
            ; <==== Until here
        Next
    EndIf
Next



>Running:(3.3.14.2):C:\Program Files\AutoIt3\autoit3.exe "D:\Taylan\Projects\AU3\Browser\TimesMe\TimesMe.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
Okay inside that div: AID_1460373684268_title
Okay inside that div: AID_1460373684268_close
Okay inside that div: AID_1460373684268_body
Div2: AID_1460373684268
It's okay we found this
IsObj($Frame) = 1
--> IE.au3 T3.0-2 Warning from function _IEGetObjById, $_IESTATUS_NoMatch (serviceNo_input_value)
--> IE.au3 T3.0-2 Warning from function _IEGetObjByName, $_IESTATUS_NoMatch (Name: searchCond.serviceNo, Index: 0)
--> IE.au3 T3.0-2 Warning from function _IEFrameGetObjByName, $_IESTATUS_NoMatch (No frames matching name)
--> IE.au3 T3.0-2 Warning from function _IEFormGetObjByName, $_IESTATUS_NoMatch
--> IE.au3 T3.0-2 Error from function _IEFormElementGetObjByName, $_IESTATUS_InvalidObjectType
Okay inside that div: AID_1460373684268
+>16:23:55 AutoIt3.exe ended.rc:0
+>16:23:55 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 1.546

I have made a few other tries without modifying your suggestion - I didn't know if it would be successful, so I have tried all the 5 ways to get an object, but all failed

Also thank you for explaining the logic for going inside these two DIVs :)

TY.

Link to comment
Share on other sites

Now that you have the second DIV , use it to get the iframe inside :

$oFrames = _IEFrameGetCollection ($div2)
$iNumFrames = @extended
For $i = 0 to ($iNumFrames - 1)
    $oFrame = _IEFrameGetCollection ($div2, $i)
    ;check here for the correct iframe
Next
Edited by Juvigy
spell check
Link to comment
Share on other sites

The frame didn't come (I assumed to use $oInput2, am I correct?)

$oInputs = _IETagNameGetCollection($oIE, "div")
For $oInput In $oInputs
    If StringLeft($oInput.id,4) = "AID_" Then ;to check if it's the correct div
        ConsoleWrite("Okay inside that div: " & $oInput.id & @CRLF )
        $oInputs2 = _IETagNameGetCollection($oInput, "div")
        For $oInput2 In $oInputs2
            ConsoleWrite("Div2: " & $oInput2.id & @CRLF )
            $oFrames = _IEFrameGetCollection($oInput2)
            $iNumFrames = @extended
            ConsoleWrite("Number of frames: " & $iNumFrames & @CRLF)
            For $i = 0 to ($iNumFrames - 1)
                $oFrame = _IEFrameGetCollection($oInput2, $i)
                ;check here for the correct iframe
                ConsoleWrite("Now i: " & $i & " Name: " & $oFrame.name & " ID: " & $oFrame.id & @CRLF)
            Next
        Next
    EndIf
Next



>Running:(3.3.14.2):C:\Program Files\AutoIt3\autoit3.exe "D:\Taylan\Projects\AU3\Browser\TimesMe\TimesMe.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
Okay inside that div: AID_1460390960355_title
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
Okay inside that div: AID_1460390960355_close
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
Okay inside that div: AID_1460390960355_body
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
Div2: AID_1460390960355
Number of frames: 142
Now i: 0 Name:  ID: 
Now i: 1 Name:  ID: 
Now i: 2 Name:  ID: 
Now i: 3 Name:  ID: 
Now i: 4 Name:  ID: 
Now i: 5 Name:  ID: 
Now i: 6 Name:  ID: 
Now i: 7 Name:  ID: 
Now i: 8 Name:  ID: 
Now i: 9 Name:  ID: 
Now i: 10 Name:  ID: 
Now i: 11 Name:  ID: 
Now i: 12 Name:  ID: 
Now i: 13 Name:  ID: 
Now i: 14 Name:  ID: 
Now i: 15 Name:  ID: 
Now i: 16 Name:  ID: 
Now i: 17 Name:  ID: 
Now i: 18 Name:  ID: 
Now i: 19 Name:  ID: 
Now i: 20 Name:  ID: 
Now i: 21 Name:  ID: 
Now i: 22 Name:  ID: 
Now i: 23 Name:  ID: 
Now i: 24 Name:  ID: 
Now i: 25 Name:  ID: 
Now i: 26 Name:  ID: 
Now i: 27 Name:  ID: 
Now i: 28 Name:  ID: 
Now i: 29 Name:  ID: 
Now i: 30 Name:  ID: 
Now i: 31 Name:  ID: 
Now i: 32 Name:  ID: 
Now i: 33 Name:  ID: 
Now i: 34 Name:  ID: 
Now i: 35 Name:  ID: 
Now i: 36 Name:  ID: 
Now i: 37 Name:  ID: 
Now i: 38 Name:  ID: 
Now i: 39 Name:  ID: 
Now i: 40 Name:  ID: 
Now i: 41 Name:  ID: 
Now i: 42 Name:  ID: 
Now i: 43 Name:  ID: 
Now i: 44 Name:  ID: 
Now i: 45 Name:  ID: 
Now i: 46 Name:  ID: 
Now i: 47 Name:  ID: 
Now i: 48 Name:  ID: 
Now i: 49 Name:  ID: 
Now i: 50 Name:  ID: 
Now i: 51 Name:  ID: 
Now i: 52 Name:  ID: 
Now i: 53 Name:  ID: 
Now i: 54 Name:  ID: 
Now i: 55 Name:  ID: 
Now i: 56 Name:  ID: 
Now i: 57 Name:  ID: 
Now i: 58 Name:  ID: 
Now i: 59 Name:  ID: 
Now i: 60 Name:  ID: 
Now i: 61 Name:  ID: 
Now i: 62 Name:  ID: 
Now i: 63 Name:  ID: 
Now i: 64 Name:  ID: 
Now i: 65 Name:  ID: 
Now i: 66 Name:  ID: 
Now i: 67 Name:  ID: 
Now i: 68 Name:  ID: 
Now i: 69 Name:  ID: 
Now i: 70 Name:  ID: 
Now i: 71 Name:  ID: 
Now i: 72 Name:  ID: 
Now i: 73 Name:  ID: 
Now i: 74 Name:  ID: 
Now i: 75 Name:  ID: 
Now i: 76 Name:  ID: 
Now i: 77 Name:  ID: 
Now i: 78 Name:  ID: 
Now i: 79 Name:  ID: 
Now i: 80 Name:  ID: 
Now i: 81 Name:  ID: 
Now i: 82 Name:  ID: 
Now i: 83 Name:  ID: 
Now i: 84 Name:  ID: 
Now i: 85 Name:  ID: 
Now i: 86 Name:  ID: 
Now i: 87 Name:  ID: 
Now i: 88 Name:  ID: 
Now i: 89 Name:  ID: 
Now i: 90 Name:  ID: 
Now i: 91 Name:  ID: 
Now i: 92 Name:  ID: 
Now i: 93 Name:  ID: 
Now i: 94 Name:  ID: 
Now i: 95 Name:  ID: 
Now i: 96 Name:  ID: 
Now i: 97 Name:  ID: 
Now i: 98 Name:  ID: 
Now i: 99 Name:  ID: 
Now i: 100 Name:  ID: 
Now i: 101 Name:  ID: 
Now i: 102 Name:  ID: 
Now i: 103 Name:  ID: 
Now i: 104 Name:  ID: 
Now i: 105 Name:  ID: 
Now i: 106 Name:  ID: 
Now i: 107 Name:  ID: 
Now i: 108 Name:  ID: 
Now i: 109 Name:  ID: 
Now i: 110 Name:  ID: 
Now i: 111 Name:  ID: 
Now i: 112 Name:  ID: 
Now i: 113 Name:  ID: 
Now i: 114 Name:  ID: 
Now i: 115 Name:  ID: 
Now i: 116 Name:  ID: 
Now i: 117 Name:  ID: 
Now i: 118 Name:  ID: 
Now i: 119 Name:  ID: 
Now i: 120 Name:  ID: 
Now i: 121 Name:  ID: 
Now i: 122 Name:  ID: 
Now i: 123 Name:  ID: 
Now i: 124 Name:  ID: 
Now i: 125 Name:  ID: 
Now i: 126 Name:  ID: 
Now i: 127 Name:  ID: 
Now i: 128 Name:  ID: 
Now i: 129 Name:  ID: 
Now i: 130 Name:  ID: 
Now i: 131 Name:  ID: 
Now i: 132 Name:  ID: 
Now i: 133 Name:  ID: 
Now i: 134 Name:  ID: 
Now i: 135 Name:  ID: 
Now i: 136 Name:  ID: 
Now i: 137 Name:  ID: 
Now i: 138 Name:  ID: 
Now i: 139 Name:  ID: 
Now i: 140 Name: home_iframe ID: 
Now i: 141 Name:  ID: 
Okay inside that div: AID_1460390960355
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
--> IE.au3 T3.0-2 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)
+>21:22:36 AutoIt3.exe ended.rc:0
+>21:22:36 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 1.931

Even if inside the DIV, I'm unable to get that frame ID or name. But in the above screenshot, I'm able to that the frame name / ID actually exists

TY.

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

×
×
  • Create New...