Danp2 Posted August 8, 2018 Posted August 8, 2018 28 minutes ago, Pagi said: Doesn't work Does this mean that the link isn't found? Or that the _IEAction command fails? Or ??? P.S. You could add some ConsoleWrite command inside your For loop so that you can "observe" as each link in processed, whether the code inside the If is triggered, etc. Latest Webdriver UDF Release Webdriver Wiki FAQs
Pagi Posted August 8, 2018 Author Posted August 8, 2018 Yeah, sorry, I forgot to mention it. I added Else MsgBox($MB_SYSTEMMODAL,"Error", "not found") That means the text was not found. I have tested it on all menu items and no text was found because this else statement always return.
Danp2 Posted August 8, 2018 Posted August 8, 2018 Your ExitLoop is in the wrong place, which would have been more apparent if you had added the ConsoleWrite commands that I previously suggested. Latest Webdriver UDF Release Webdriver Wiki FAQs
Pagi Posted August 10, 2018 Author Posted August 10, 2018 ConsoleWrite($oLink.innerText) Returns "Menu Item 1" only.
Danp2 Posted August 10, 2018 Posted August 10, 2018 23 minutes ago, Pagi said: ConsoleWrite($oLink.innerText) Returns "Menu Item 1" only. Right... because as I stated before On 8/8/2018 at 3:48 PM, Danp2 said: Your ExitLoop is in the wrong place Try running this code (page needs to be already open in IE) -- #include <IE.au3> Local $oIE = _IEAttach("pagi_blog", "url") $oDiv = _IEGetObjById($oIE, "submenu2") $oLinks = _IETagNameGetCollection($oDiv, "a") ;$oLinks = _IELinkGetCollection($oDiv) For $oLink In $oLinks ConsoleWrite($oLink.innerText & @CRLF) If StringInStr($oLink.innerText,"Menu Item 1") Then ConsoleWrite('Found link!' & @CRLF) _IEAction($oLink, "click") ExitLoop EndIf Next Latest Webdriver UDF Release Webdriver Wiki FAQs
Pagi Posted August 13, 2018 Author Posted August 13, 2018 (edited) Ok, I finally got it. Here´s how I solved it. Local $sMyString = "Menu Item 2" Local $oLinks = _IELinkGetCollection($oIE) For $oLink In $oLinks Local $sLinkText = _IEPropertyGet($oLink, "innerText") If StringInStr($sLinkText, $sMyString) Then _IEAction($oLink, "click") ExitLoop EndIf Next Danp2, thank you very much for your support! Edited August 13, 2018 by Pagi
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