Jump to content

I Cannot reach some command in a page...


Recommended Posts

Hello everyone,

I am trying to automate some procedures for my job, unfortunately I can't reach some commands in a page that I found already open, so I refer to it by using " _IEAttach("title")" than I point the form and than the object, I got an error when try to get the object, I even tried without the form reference, Always get an error.

 

This is the code I wrote and it does not work:

 If WinExists("Lista copie reclami per riassegnazione") == 0 Then MsgBox(1,"Controllo riassegnazioni","Le riassegnazioni sono chiuse, apri la pagina e DOPO clicca OK")
$RiassegnazioniHandle = _IEAttach("Lista copie reclami per riassegnazione")
$oForm = _IEFormGetObjByName($RiassegnazioniHandle, "form1")
$CBAF = _IEFormElementGetObjByName($oForm, "text_T1_R1_E1")

;$CBAF = _IEGetObjByName ($RiassegnazioniHandle, "text_T1_R1_E1");Punta il campo dal codice

 

 

this is the button code I need to click:

<a tabindex="22" title="Mostra lista reclami" class="linkbutton_little" style="font-size: 1em;" onclick="confermaVecchiValori();" href="#">
       Conferma
      </a>

Actualy I should do other thing in this page but I believe once I know How to refer the "Conferma" button I could reach the otherones.

Someone could help me with this please?

Thank you,

Marco

pagina.html

Link to comment
Share on other sites

53 minutes ago, Danp2 said:

Your "button" is actually a link, so you should be able to do this --

_IELinkClickByText($RiassegnazioniHandle, "Conferma")

 

   If WinExists("Lista copie reclami per riassegnazione") == 0 Then MsgBox(1,"Controllo riassegnazioni","Le riassegnazioni sono chiuse, apri la pagina e DOPO clicca OK")
$RiassegnazioniHandle = _IEAttach("Lista copie reclami per riassegnazione")
$oForm = _IEFormGetObjByName($RiassegnazioniHandle, "form1")
_IELinkClickByText($RiassegnazioniHandle, "Conferma")

Unfortunately this is not working properly:

 

IE.au3 T3.0-1 Warning from function _IELinkClickByText, $_IEStatus_NoMatch

Any other tip?

Link to comment
Share on other sites

You may need to "drill down" into the DOM since the link is contained within a table, which is within the form. Another option is to try this modified example from the help file --

#include <IE.au3>

Local $oIE = _IEAttach("Lista copie reclami per riassegnazione")
Local $sMyString = "Conferma"
Local $oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
    Local $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, $sMyString) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next

Does this work for you?

Link to comment
Share on other sites

This is the general idea (untested) --

#include <IE.au3>

Local $sMyString = "Conferma"

Local $oIE = _IEAttach("Lista copie reclami per riassegnazione")
Local $oForm = _IEFormGetObjByName($oIE, "form1")
Local $oTable = _IETableGetCollection($oForm, 5)
Local $oLinks = _IETagNameGetCollection($oTable, "a")

For $oLink In $oLinks
    Local $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, $sMyString) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next

 

Link to comment
Share on other sites

That seems to work fine with me :

#include <IE.au3>

Local $sMyString = "Conferma"

Local $oIE = _IEAttach("", "instance", 1)
ConsoleWrite(IsObj($oIE) & @CRLF)
Local $oForm = _IEFormGetObjByName($oIE, "form1")
ConsoleWrite(IsObj($oForm) & @CRLF)
$oObj = _IEGetObjById($oIE, "layout")
ConsoleWrite(IsObj($oObj) & @CRLF)

Local $oTables = _IETableGetCollection($oObj)
ConsoleWrite(IsObj($oTables) & "/" & $oTables.length & @CRLF)

For $oTable In $oTables
  Local $oLinks = _IETagNameGetCollection($oTable, "a")
  For $oLink In $oLinks
    Local $sLinkText = _IEPropertyGet($oLink, "innerText")
    ConsoleWrite($sLinkText & @CRLF)
    If StringInStr($sLinkText, $sMyString) Then
      ConsoleWrite("found " & $oLink.getAttribute("title") & @CRLF)
      _IEAction($oLink, "click")
      ExitLoop 2
    EndIf
  Next
Next

 

Link to comment
Share on other sites

Hello Nine,

I want to thank you for your effort and help,

unfortunately it does not work,

I get this error message:

C:\Users\MarcoMonte\Desktop\Ambiente autoit\autoit-v3\install\SciTe\..\autoit3.exe" /ErrorStdOut "C:\Users\MarcoMonte\Desktop\Grafica.au3"   
1
--> IE.au3 T3.0-1 Warning from function _IEFormGetObjByName, $_IEStatus_NoMatch
0
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (layout)
0
--> IE.au3 T3.0-1 Error from function _IETableGetCollection, $_IEStatus_InvalidDataType
"C:\Users\MarcoMonte\Desktop\Grafica.au3" (239) : ==> Variable must be of type "Object".:
ConsoleWrite(IsObj($oTables) & "/" & $oTables.length & @CRLF)
ConsoleWrite(IsObj($oTables) & "/" & $oTables^ ERROR
>Exit code: 1    Time: 3.082

 

The page is open and the "Conferma" button works fine if you click it with the mouse, this is driving me crazy

Link to comment
Share on other sites

I have based my script on the html file you provided and it is working fine with me.  So I must assume the page has changed from what you posted and the test you have attempted.  Can we have access to the web site you are using ?  Otherwise make sure you got the right page or provide the newest html page.

Link to comment
Share on other sites

Sorry Nine,

I did not understand I should have change the first line,

I modified this line "Local $oIE = _IEAttach("", "instance", 1)" IN this line: "Local $oIE = _IEAttach("Lista copie reclami per riassegnazione")"

And now it works fine, I will study your script to adapt it to the others commands in the same page, thank you very much.

Marco

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