dbb1480 Posted March 3, 2019 Posted March 3, 2019 Hi All, I have been at this for about a week and a half now and can't figure it out. I am trying to click a share button on an IE webpage here is the html <div class="social-info social-actions d-fl ai-c jc-c"> <ul class="listing-actions-con d-fl ai-c jc-sb" id="7892-listing-actions"> <li class="d-fl ai-c likes" data-count="0"> <a class="auth-required unlike auth-required f-hide" data-ajax="true" data-ajax-href="/listing/7892/unlike" data-authorized="true" data-pa-attr-listing_id="7892" data-pa-attr-location="like_bottom" data-pa-click-type="button" data-pa-name="unlike" data-post-id="7892"> <i class="icon liked"></i> </a> <a class="auth-required like auth-required " data-ajax="true" data-ajax-href="/listing/7892/like" data-authorized="true" data-pa-attr-listing_id="7892" data-pa-attr-location="like_bottom" data-pa-click-type="button" data-pa-name="like" data-pmrd="{ "usehref" : "true"}" data-post-id="7892"> <i class="icon like"></i> </a> <div class="like-count-con"> <span class="count f-hide"></span> </div> </li> <li class="d-fl ai-c"> <a class="comment auth-required" data-pa-name="comment" data-pmrd="{ "usehref" : "true"}" href="item-7982#comment"> <i class="icon comment-gray"></i> </a> <span class="count f-hide"></span> </li> <li class="d-fl ai-c"> <a class="share" data-pa-attr-listing_id="7892" data-pa-click-type="button" data-pa-name="share" data-target="#share-popup" data-toggle="modal"> <i class="icon share-gray"></i> </a> </li> </ul> </div> I am trying to click the class share button but just can't figure out how. I am sure it is stupid easy and I am just doing something done. #include <IE.au3> #include <MsgBoxConstants.au3> ;Assume other code exists before this that navigating to needed webpage Local $oIE = _IEAttach($oIE) Local $oForm = _IEGetObjByID($oIE, "7892") MsgBox($MB_SYSTEMMODAL, "Line1", $oForm.innertext) Local $oElements = _IETagNameAllGetCollection($oForm) For $oElement In $oElements If $oElement.id Then MsgBox($MB_SYSTEMMODAL, "Element Info", "Tagname: " & $oElement.tagname & @CRLF & "id: " & $oElement.id & @CRLF & "innerText: " & $oElement.innerText) Next I am just not getting the element to get the button. Still pretty new to AutoIT so any help would be appreciated. Thank You
rm4453 Posted March 3, 2019 Posted March 3, 2019 Hey see below: ;================================ ; ; Credit To: PsaltyDS ; ; Found @: https://www.autoitscript.com/forum/topic/116614-_ie-how-to-click-item-by-class/ ; ;================================ $oFound = "" $colLinks = _IELinkGetCollection($oIE) For $oLink In $colLinks If $oLink.className & "" = "share" Then $oFound = $oLink ExitLoop EndIf Next If IsObj($oFound) Then MsgBox(64, "Success", "Found it!") Else MsgBox(16, "Failed", "Not found.") EndIf
Nine Posted March 3, 2019 Posted March 3, 2019 Would also work using : $colTags = _IETagNameGetCollection($oIE, "a") For $oTag In $colTags If $oTag.className = "share" Then $oFound = $oTag ExitLoop EndIf Next Just make sure there is no frame around “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
dbb1480 Posted March 4, 2019 Author Posted March 4, 2019 Thanks Nine, your code worked! I must have tried some variation of that like 30 times.... oh well it works now! Thank You!
Nine Posted March 4, 2019 Posted March 4, 2019 10 hours ago, dbb1480 said: Thanks Nine, your code worked! I must have tried some variation of that like 30 times.... oh well it works now! Thank You! “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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