Pagi Posted July 20, 2018 Posted July 20, 2018 <a href="index.php=4143b27b41db0a40c499202865c3e24d" class="menuitem " target="\_self"> "Menu Item 1" </a> Can you tell me if it´s possible to click this menu button? If yes, how? Cause I have no idea, I think i should use _IETagNameGetCollection
Moderators JLogan3o13 Posted July 20, 2018 Moderators Posted July 20, 2018 (edited) Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team Edited July 20, 2018 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Danp2 Posted July 20, 2018 Posted July 20, 2018 How about using _IELinkClickByText? Latest Webdriver UDF Release Webdriver Wiki FAQs
Pagi Posted July 23, 2018 Author Posted July 23, 2018 Func menu() $currenturl = _IEPropertyGet($oIE,"locationurl") $oDivs = _IETagNameGetCollection($currenturl, "div") For $oDiv In $oDivs If StringInStr($oDiv.innertext,"Menu Item 1") Then _IEAction($oDiv, "click") Else ConsoleWrite($oDiv.innertext) EndIf Next EndFunc Like this? Because it does not work..
Danp2 Posted July 23, 2018 Posted July 23, 2018 12 minutes ago, Pagi said: $currenturl = _IEPropertyGet($oIE,"locationurl") $oDivs = _IETagNameGetCollection($currenturl, "div") Not sure why you are doing this, as you can't pass the URL as the first parameter of _IETagNameGetCollection. Try this instead -- $oDivs = _IETagNameGetCollection($oIE, "div") However, I was suggesting to use _IELinkClickByText, like this -- _IELinkClickByText($oIE, "Menu Item 1") This may not work given the fact that it is part of a menu. Latest Webdriver UDF Release Webdriver Wiki FAQs
Pagi Posted July 26, 2018 Author Posted July 26, 2018 $oClasses = _IETagNameGetCollection($oIE, "class") For $oClass in $oClasses If StringInStr($oClass.innertext, "Menu Item 1") Then _IEAction($oClass, "click") EndIf Next I tried to identify it by the class but it still doesn´t work. Any other idea? Or is there any mistake? Danp, thanks for your reply, _IELinkClickByText does´nt work and also I don´t want to solve it like that. I just need to identify some element and then click on the menu button.
Danp2 Posted July 26, 2018 Posted July 26, 2018 Maybe this is what you want -- $oDivs = _IETagNameGetCollection($oIE, "div") For $oDiv in $oDivs If StringInStr($oDiv.innertext, "Menu Item 1") Then _IEAction($oDiv, "click") EndIf Next Latest Webdriver UDF Release Webdriver Wiki FAQs
Danp2 Posted July 30, 2018 Posted July 30, 2018 Right ... Except you targeted 'class' whereas I targeted 'div'. Latest Webdriver UDF Release Webdriver Wiki FAQs
Pagi Posted August 1, 2018 Author Posted August 1, 2018 But there is no div in HTML code.. Only tag <a> and class but problem with class is, that the same class has got more elements
Danp2 Posted August 1, 2018 Posted August 1, 2018 Ok... but you had previously shown code where you were searching by div, so this led me to believe that the link was contained within a div. You've only shown us a single element, so it's not possible to guess the context that it resides in. Suggest that you shown us more of the surrounding HTML code. Also, it would be good to know if there are any events attached to these elements. If so, which ones? Latest Webdriver UDF Release Webdriver Wiki FAQs
Danp2 Posted August 1, 2018 Posted August 1, 2018 Have you tried accessing the div element and then the contained links? Something like this -- $oDiv = _IEGetObjById($oIE, "submenu2") $oLinks = _IETagNameGetCollection($oDiv, "a") For $oLink In $oLinks If StringInStr($oLink.innerText,"Menu Item 1") Then _IEAction($oLink, "click") ExitLoop EndIf Next Latest Webdriver UDF Release Webdriver Wiki FAQs
Pagi Posted August 2, 2018 Author Posted August 2, 2018 It´s working! But only on Main Button. I think the reason are apostrophes. I tried to include them in code but nothing...
Danp2 Posted August 2, 2018 Posted August 2, 2018 @Pagi Not sure what you mean here by "Main Button" and apostrophes. You'll need to provide further details if you want additional help. Latest Webdriver UDF Release Webdriver Wiki FAQs
Pagi Posted August 2, 2018 Author Posted August 2, 2018 It´s not working on other buttons, only on button called "Main Button". Look at the screenshot up and u will understand.
Danp2 Posted August 2, 2018 Posted August 2, 2018 You should show your code because the code I posted was intended to target "Menu Item 1". If you've changed the code so that it now works for "Main Button", then it helps if you include these details in your responses. Also, since you posted a screenshot instead of the actual HTML code, it isn't possible for me to take a closer look at the HTML. Latest Webdriver UDF Release Webdriver Wiki FAQs
Pagi Posted August 8, 2018 Author Posted August 8, 2018 (edited) Page is not uploaded yet so <a> href links will not work. Here is the offline file of the HTML. That´s just random links I put in Pagi_blog.html Edited August 8, 2018 by Pagi
Danp2 Posted August 8, 2018 Posted August 8, 2018 Post your code. Latest Webdriver UDF Release Webdriver Wiki FAQs
Pagi Posted August 8, 2018 Author Posted August 8, 2018 $oDiv = _IEGetObjById($oIE, "submenu2") $oLinks = _IETagNameGetCollection($oDiv, "a") For $oLink In $oLinks If StringInStr($oLink.innerText,"Menu Item 1") Then _IEAction($oLink, "click") EndIf ExitLoop Next EndFunc Doesn´t work. If I write in code "Main Button" to target Main Button like this, $oDiv = _IEGetObjById($oIE, "submenu2") $oLinks = _IETagNameGetCollection($oDiv, "a") For $oLink In $oLinks If StringInStr($oLink.innerText,"Main Button") Then _IEAction($oLink, "click") EndIf ExitLoop Next EndFunc it works. But for menu items 1,2,3,4,5 not.
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