MarcoMonte Posted October 20, 2020 Share Posted October 20, 2020 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 More sharing options...
Danp2 Posted October 20, 2020 Share Posted October 20, 2020 Your "button" is actually a link, so you should be able to do this -- _IELinkClickByText($RiassegnazioniHandle, "Conferma") Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
GokAy Posted October 20, 2020 Share Posted October 20, 2020 (edited) Hey Marco, Nvm, my bad Edited October 20, 2020 by GokAy Bad advice... Sorry Link to comment Share on other sites More sharing options...
MarcoMonte Posted October 20, 2020 Author Share Posted October 20, 2020 Thank you both for these advices, I will try Tomorrow as I come back to work and let you know how it is gone. see you soon Marco Link to comment Share on other sites More sharing options...
MarcoMonte Posted October 20, 2020 Author Share Posted October 20, 2020 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 More sharing options...
Danp2 Posted October 20, 2020 Share Posted October 20, 2020 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? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MarcoMonte Posted October 20, 2020 Author Share Posted October 20, 2020 Hello, no unfortunately it is not working, could you link me a guide for drilling down DOM pls? Thanks a lot. Marco Link to comment Share on other sites More sharing options...
Danp2 Posted October 20, 2020 Share Posted October 20, 2020 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 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MarcoMonte Posted October 22, 2020 Author Share Posted October 22, 2020 Hello guys, this is not working, maybe I should give up and go with a mouseclick... Link to comment Share on other sites More sharing options...
Nine Posted October 22, 2020 Share Posted October 22, 2020 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 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
MarcoMonte Posted October 22, 2020 Author Share Posted October 22, 2020 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 More sharing options...
Nine Posted October 22, 2020 Share Posted October 22, 2020 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. MarcoMonte 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
MarcoMonte Posted October 22, 2020 Author Share Posted October 22, 2020 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 More sharing options...
Nine Posted October 22, 2020 Share Posted October 22, 2020 Glad it worked for you MarcoMonte 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now