Jump to content

IE.au3 - Error to get objects by frame


Recommended Posts

Hello guys,

Imagine that you developed a code to automate web functions and when you finish and make tests in another systems/computers you discovered that there is a big problem and the worst...you did not find the solution. Well...its me Lol

I apreciate the great help you provide in this forum, i aways find solutions so thankyou very much, but its my first post :D

The problem is i can't get objects by frame, let's see an example:

#Include <IE.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>

_IEErrorNotify(True)
$oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

Local $oIE = _IECreate ("http://gsi.itau")
_IELoadWait($oIE)

_IEImgClick($oIE, "cadeado_aberto.jpg", "src")

Local $Frame = _IEFrameGetCollection($oIE, 2)
Local $Inputs = _IETagNameGetCollection($Frame, "input")

So what im trying to do is:

1 - Open a page
2 - Click on a button to access an different area (a direct url dont work)
3 - On the new page there are 3 frames and i need to access one of then so that's ok i can access this frame
4 - When i try to get the objects using "_IETagNameGetCollection",  "_IETagNameGetCollection" or any command that try to get objects by selected frame i received an error. There are different errors, the very common is: 

"C:\Program Files\AutoIt3\Include\IE.au3" (1773) : ==> The requested action with this object has failed.:
Return SetError($_IESTATUS_Success, 0, $oObject.document)
Return SetError($_IESTATUS_Success, 0, $oObject^ ERROR

And i the detailed error: (using _IEErrorNotify)

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "D:\teste.au3"    
--> IE.au3 T3.0-1 Warning from function _IEImgClick, $_IESTATUS_NoMatch
teste.au3 (1773) : ==> COM Error intercepted !
    err.number is:      0x80020009
    err.windescription: Exception occurred.

    err.description is:     Access is denied.

    err.source is:      
    err.helpfile is:    C:\Windows\System32\mshtml.hlp
    err.helpcontext is:     0
    err.lastdllerror is:    0
    err.scriptline is:  1773
    err.retcode is:     0x80070005

teste.au3 (1800) : ==> COM Error intercepted !
    err.number is:      0x000000A9
    err.windescription: Variable must be of type 'Object'.
    err.description is:     
    err.source is:      
    err.helpfile is:    
    err.helpcontext is:     
    err.lastdllerror is:    0
    err.scriptline is:  1800
    err.retcode is:     0x00000000

teste.au3 (1800) : ==> COM Error intercepted !
    err.number is:      0x000000A9
    err.windescription: Variable must be of type 'Object'.
    err.description is:     
    err.source is:      
    err.helpfile is:    
    err.helpcontext is:     
    err.lastdllerror is:    0
    err.scriptline is:  1800
    err.retcode is:     0x00000000

>Exit code: 0    Time: 0.9172

The source code of a "new page"
 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 
<HTML><HEAD>
 
 
    
 
<META name="GENERATOR" content="IBM WebSphere Page Designer V3.5.3 for Windows">
<META http-equiv="Content-Style-Type" content="text/css">
<TITLE>Superintendência Técnica de Segurança em Informática</TITLE>
<link REL="stylesheet" TYPE="TEXT/css" href="seguranca.css">
<style> 
A{
    FONT-SIZE: 11px;
    COLOR: #12357e;
    FONT-FAMILY: Arial;
    text-decoration:underline;
}
A:active {
    COLOR: red;
}
A:hover {
    COLOR: red;
}
BODY{
scrollbar-face-color: #F1F3F6; 
scrollbal-shadow-color: #D5D9DE; 
scrollbar-highlight-color: #DCDDED; 
scrollbar-3dlight-color: #orage; 
scrollbar-darkshadow-color: #00008B; 
scrollbar-track-color: #F1F3F6; 
scrollbar-arrow-color: #0048AA;
}
</style>
<script language="javascript"> 
//==================================================================================================//
//  Função........: alertaDeMensagem()
//  Autor.........: Fabrica de Software.
//  Objetivo......: Exibe mensagem enviada como parâmetro através de alerta
//=================================================================================================//
function alertaDeMensagem(){
 
    mensagem = "";
 
    if (document.forms[0].elements['VLRBOTAO'].value == "JANELACONFIRMAR"){
        document.forms[0].elements['VLRBOTAO'].value = "";
        resposta  = confirm(mensagem);
        if(resposta){
            submeter('CONFIRMAR');
        }
    }else{
        if (mensagem != ""){
            alert(mensagem);
        }
    }
}
//==================================================================================================//
//  Função........: submeter(valor)
//  Autor.........: Fabrica de Software.
//  Objetivo......: submete valor botao
//=================================================================================================//
function submeter(valor){
    document.forms[0].elements['VLRBOTAO'].value = valor;
    document.forms[0].submit();
}
//==================================================================================================//
//  Função........: valorEnter()
//  Autor.........: Fabrica de Software.
//  Objetivo......: submete ok qdo enter
//=================================================================================================//
function valorEnter(){
    if (event.keyCode == 13) {
        submeter('PESQUISAR');
    }
}
//==================================================================================================//
//  Função........: abreJanela()
//  Autor.........: Fabrica de Software.
//  Objetivo......: abre janela gsi
//  Parâmetros....: 
//=================================================================================================//
function abreJanela() { 
    if (document.forms[0].elements['VLRBOTAO'].value == "CHAMAJANELA"){
        document.forms[0].elements['VLRBOTAO'].value = "";
        retorno = showModalDialog("DVB5Janela.jsp",null,"dialogWidth: 480px; dialogHeight: 380px"); 
    }
}
//==================================================================================================//
//  Função........: selecionar()
//  Autor.........: Fabrica de Software.
//  Objetivo......: seleciona combo 
//  Parâmetros....: 
//=================================================================================================//
function selecionar() { 
    if (document.forms[0].elements['SEL_AMBIENTE'].selectedIndex > 0){
        submeter('SELECIONAR');
    }
}
function chamaDVJK() {  
    top.lateral.location = "Menu.jsp";
    top.Main.location = "inicio?hptAppId=DVJK&hptExec=Y&hptRecord=DVJKRU&PGMCHAMOU=L";
}
</script>
</HEAD>
 
<BODY onload="abreJanela();alertaDeMensagem();" background="images/fundo_Acessos.jpg"  scroll="no" marginwidth="0" marginheight="0" leftMargin="0" topMargin="0">
    <FORM METHOD="POST" ACTION="https://wscorp4.itau/dv/inicio?hptAppId=DVB5&hptExec=Y&hptRecord=DVB5RU">   
    <INPUT TYPE=HIDDEN NAME="VLRBOTAO" VALUE="">
    <INPUT TYPE=HIDDEN NAME="TAM_AMBIENTE" VALUE="">
 
 
 
 
    
 
 
    <IMG height=20 src="images/desbloqueio.gif">    
        <table  class="Letra" cellpadding="5" cellspacing="5">
            <tr>
                <TD style="border:1px navy solid; ">
                    Atenção: caso você tenha <font style="color:red">esquecido</font> a senha, não utilize esta função.<br>
                    Entre em contato com um "solicitante GSI" da sua área e solicite à ele uma nova senha.<br>
                    <A class=letra HREF="Javascript:chamaDVJK();">Clique aqui para visualizar a relação dos "solicitantes GSI" de sua área</A><br>
                </TD>
            </tr>
        </table>
        <table  class="Letra" cellpadding="0" cellspacing="0">
            <tr>
                <TD width="134">
                    <table border=0 class="Letra" cellpadding="0" cellspacing="0">
                        <tr>
                            <td> Funcional:<br>ou</TD>
                            <TD>
                                <INPUT style="width:60px;" onkeypress="valorEnter();" class="Campo1" TYPE=TEXT NAME="NUMFUNCR_PESQ" SIZE=9 MAXLENGTH=9 VALUE="">
                                <INPUT TYPE=HIDDEN NAME="NUMFUNCR" VALUE="">
                            </TD>
                        </tr>
                        <tr>
                            <TD width="65px"> Userid:</TD>
                            <TD>
                                <INPUT style="text-transform:uppercase;width:60px;"  onkeypress="valorEnter();" class="Campo1" TYPE=TEXT NAME="USERID_PESQ" SIZE=8 MAXLENGTH=8 VALUE="">
                                <INPUT TYPE=HIDDEN NAME="USERID" VALUE="">
                            </TD>
                        </tr>
                    </table>
                </TD>
                <TD>
                
                    <img src="images/botok.gif" border="0" style="cursor:hand" onClick="submeter('PESQUISAR');" style="cursor:hand">
                
                </TD>
            </tr>
            <tr>
                <TD colspan=2>
                    <table class="Letra">
                        
                    </table>
                    <INPUT TYPE=HIDDEN NAME="NOMEFUNC" VALUE="">
                </TD>
            </tr>
            <tr>
                <TD colspan=2>
                 
                </TD>
            </tr>
        </table>
        <br>                     
    </FORM>
</BODY>
</HTML>



Im already searched for solutions in many forums here like bellow and i know that there is a problem with a specific Windows KB buts i saw another situations where the KB is not present.
Im using a last AutoIT version 3.5.4 and IE.au3 version is 3.3.12.0.
Ok so lets ask: There is a way to solve this? Maybe an alternative way? 

Thankyou!!

 

Link to comment
Share on other sites

  • Developers

@Hernanizero

Try using the reply box in stead of the report Button when you want to reply to a post! ;)

Quote

Oooops....really? Well...i can't get objects without manage frames. can you tell me how can i manage some objects like NAME="NUMFUNCR_PESQ" in Input?

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

1 hour ago, Danp2 said:

@Hernanizero Based on the posted HTML, I would suggest something like this --

$oForm = _IEFormGetCollection($oIE, 0)
$oInput = _IEFormElementGetObjByName($oForm, "NUMFUNCR_PESQ")

 

hmmm i tried this but i did not get the object.

#Include <IE.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>

_IEErrorNotify(True)
$oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

$oIE = _IECreate ("http://gsi.itau")
_IELoadWait($oIE)

_IEImgClick($oIE, "cadeado_aberto.jpg", "src")
;~ _IELoadWait($oIE)

$oForm = _IEFormGetCollection($oIE, 0)
$oInput = _IEFormElementGetObjByName($oForm, "NUMFUNCR_PESQ")
MsgBox(0, "", _IEpropertyget($oInput, "innerhtml"))

Result:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "D:\teste.au3"    
--> IE.au3 T3.0-1 Warning from function _IEFormGetCollection, $_IESTATUS_NoMatch
--> IE.au3 T3.0-1 Error from function _IEFormElementGetObjByName, $_IESTATUS_InvalidDataType
--> IE.au3 T3.0-1 Error from function _IEPropertyGet, $_IESTATUS_InvalidDataType
>Exit code: 0    Time: 3.903

Link to comment
Share on other sites

It's difficult to know exactly why it isn't working since we can't access the site. You previously mentioned frames, but then posted HTML without any frames. Perhaps the issue is that there are frames, but you showed us the HTML from one of the frames instead of the main "parent" window. <shrug>

At this point, I would recommend looking at the help file example for _IEFrameGetCollection and adapt it to work on your desired site so that you can determine how many frames are involved, which one contains your desired elements, etc.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...