Jump to content
taylansan

Another iFrame and element question

Recommended Posts

taylansan

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.

Share this post


Link to post
Share on other sites
Juvigy

First - check if you got the correct iframe.

Then try something like this :
 

$oFrames = _IEFrameGetCollection ($oIE)
$iNumFrames = @extended
For $i = 0 to ($iNumFrames - 1)
    $oFrame = _IEFrameGetCollection ($oIE, $i)
    ;check here for the correct iframe
Next

 

Share this post


Link to post
Share on other sites
taylansan

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.

Share this post


Link to post
Share on other sites
Juvigy

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

Share this post


Link to post
Share on other sites
taylansan

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.

Share this post


Link to post
Share on other sites
Juvigy

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.

Share this post


Link to post
Share on other sites
taylansan

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.

Share this post


Link to post
Share on other sites
MichaelHB

@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

 

Share this post


Link to post
Share on other sites
markyrocks

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)

 

Share this post


Link to post
Share on other sites
MichaelHB

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

Share this post


Link to post
Share on other sites
taylansan

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.

Share this post


Link to post
Share on other sites
markyrocks
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()

Share this post


Link to post
Share on other sites
MichaelHB

@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

 

Share this post


Link to post
Share on other sites
taylansan

@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.

Share this post


Link to post
Share on other sites
Juvigy

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

Share this post


Link to post
Share on other sites
taylansan

@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.

Share this post


Link to post
Share on other sites
Juvigy

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

 

Share this post


Link to post
Share on other sites
taylansan

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.

Share this post


Link to post
Share on other sites
Juvigy

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

Share this post


Link to post
Share on other sites
taylansan

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"

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.

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

  • Similar Content

    • Seminko
      By Seminko
      Wrote a script that grabs all of the IP addresses from Netflix's IP log, checks the IPs and returns suspicious activity.
      Everything works as it should but only when _IECreate is set to visible. When visible is set to false, it fails to login for some reason.
      Any ideas what might cause it and/or how to circumvent that?
    • nooneclose
      By nooneclose
      I need to send a string of text to this popup and click on the ok button to save it.
      Here is the code I have so far:
      ;Start IE Sleep(7000) $oIE = _IECreate("http://www.google.com") Sleep(500) _IELoadWait($oIE) $hIE = _IEPropertyGet($oIE, "hwnd") ; Get Handle of the IE window Sleep(500) WinSetState($hIE, "", @SW_MAXIMIZE) ;Wait for a browser page load to complete Sleep(3000) _IENavigate($oIE, "https://properURL.com") Sleep(8000) _IELoadWait($oIE) ;Attach to a browser control embedded in another window $oIE = _IEAttach("https://"properURL.com", url") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $oIE = ' & $oIE & @CRLF & '>Error code: ' & @error & ' Extended code: 0x' & Hex(@extended) & @CRLF) ;### Debug Console Sleep(2000) ;Get the title of the webpage ;Local $wTitle = _IEPropertyGet($oIE, "title") ;MsgBox($MB_SYSTEMMODAL, "Webpage title:", $wTitle) ;Clicks the new button Sleep(3000) _IEAction($nWorkOrderB, "focus") _IEAction($nWorkOrderB, "click") Sleep(5000) ;Store the Element names where the important data will be sent ;Store the long description button Local $wLongDButton = _IEGetObjById($oIE, "m65d795a4-img") ;Store the long Description field id Local $wComments = _IEGetObjById($oIE, "ma6499a9c-rte_iframe") ;Store the ok button id that is in the long description Local $wCommOk = _IEGetObjById($oIE, "m74031266-pb") ;******************************************************************************* ; Send the stored data to the proper field ;******************************************************************************* ;Click the long description button Sleep(300) _IEAction($wLongDButton, "focus") _IEAction($wLongDButton, "click") Sleep(300) ;Sends the Comments Sleep(500) _IEAction($wComments, "focus") _IEAction($wComments, "click") Sleep(500) _IEFormElementSetValue($wComments, "hello darkness my old friend") ;Click the ok button Sleep(500) _IEAction($wCommOk, "focus") _IEAction($wCommOk, "click") Sleep(500)  
      Here is the popup:

    • hemichallenger
      By hemichallenger
      Hello,
      If anyone can help, it would be greatly appreciated. The code is just an example and similar to the issue with an internal webpage. I'm trying to autofill than click the submit button. I get the same error running the script.
      _IEFormElementSetValue, $_IESTATUS_InvalidObjectType
      IEGetObjById, $_IESTATUS_NoMatch
      Is it possible to edit the <textarea></textarea>  field with AutoIt?  If anyone could assist me on how. Than I could have a better understanding and chance in figuring it out on my main script. Thank you
      #include <IE.au3> Local $oIE1 = _IECreate ("https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_textarea") _IELoadWait($oIE1) local $oFormCollection = _IEFormGetCollection($oIE1,0) local $oid = _IEGetObjByid($oFormCollection, "iframeResult") _IEFormElementSetValue($oid, "test") sleep (2000) Local $oIE2 = _IECreate ("https://www.w3schools.com/html/tryit.asp?filename=tryhtml_scripts_intro") _IELoadWait($oIE2) $oForm2 = _IEFormGetCollection($oIE2,0) $oClickMe = _IEGetObjById($oForm2, "demo") _IEAction($oClickMe, "focus") _IEAction($oClickMe, "click")
    • Blueman
      By Blueman
      Hey Guys,
      Hope that you can help me with something, maybe this is a bug in the new version of AUTOIT but first i will check it with you to know for sure.
      I have made a simple GUI with a Embedded IE Object, then i would like to read the HTML with _IEBodyReadHTML(), easy right?
      When i use the old IE.au3 include from a year back or so, it is working fine!
      When i use the new IE.au3 include came with the new installation that is currently available on autoitscript.com it isnt working (i get a result that says; 0).
      Let me show you.
       
      Working Example
      #include <GUIConstantsEx.au3> #include <IE_EmbeddedVersioning.au3> #include <IE_PreVersion.au3> ;Older Version Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 1000, 1000) Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) Global $oIE_1 = _IECreateEmbedded() ; CREATE IE OBJECT(S) GUICtrlCreateObj($oIE_1, 355, 5, 600, 360) _IENavigate($oIE_1, "https://www.google.nl", 1) Local $CheckHTML_T = _IEBodyReadHTML($oIE_1) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) MsgBox(48,"",$CheckHTML_T) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example  
      Failing Example
      #include <GUIConstantsEx.au3> #include <IE_EmbeddedVersioning.au3> #include <IE.au3> ;New Version Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 1000, 1000) Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) Global $oIE_1 = _IECreateEmbedded() ; CREATE IE OBJECT(S) GUICtrlCreateObj($oIE_1, 355, 5, 600, 360) _IENavigate($oIE_1, "https://www.google.nl", 1) Local $CheckHTML_T = _IEBodyReadHTML($oIE_1) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) MsgBox(48,"",$CheckHTML_T) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example  
      I have attachted all files and i am testing on Windows 10 with the latest SciTe Program (Not compiled). 
      When i compile the script it is showing the same result.
      Thanks guys!
      IE_PreVersion.au3
      IE.au3
      IE_EmbeddedVersioning.au3
×