MJ36 Posted October 29, 2018 Posted October 29, 2018 How to click this button ? I Try func test () $oCorrectObj = "" $tags = $oIE.document.GetElementsByTagName("button") For $tag in $tags $class_value = $tag.GetAttribute("type") If string($class_value) = "buttont" Then $oCorrectObj = $tag MsgBox(0, "Level: ", "Level found :)") Else MsgBox(16, "Failed", "Not found.") ExitLoop EndIf Next If IsObj ( $oCorrectObj ) Then _IEAction ($oCorrectObj, "click") EndIF and func klik () Local $oFound = "" Local $oBtns = _IETagNameGetCollection($oIE, "span") For $oBtn In $oBtns If String($oBtn.classname) = "yt-uix-button-content" Then $oFound = $oBtn EndIf Next _IEAction ($oFound, "click") EndFunc Please Help Can you click it by name?
Danp2 Posted October 29, 2018 Posted October 29, 2018 Which do you need to click, the Button element or the Span? Latest Webdriver UDF Release Webdriver Wiki FAQs
MJ36 Posted October 29, 2018 Author Posted October 29, 2018 I apologize for inaccuracies of course the button
Danp2 Posted October 29, 2018 Posted October 29, 2018 If would change your _IETagNameGetCollection line to -- Local $oBtns = _IETagNameGetCollection($oIE, "button") You would then need to loop through the collection to find the correct button. Even better, you could limit the results by passing the containing div element instead of $oIE -- Local $oDiv = _IEGetObjById($oIE, "watch7-views-info") Local $oBtns = _IETagNameGetCollection($oDiv, "button") If there only one button or you know the index, you could do something like this -- Local $oDiv = _IEGetObjById($oIE, "watch7-views-info") Local $oBtn = _IETagNameGetCollection($oDiv, "button", 0) _IEAction ($oBtn, "click") Latest Webdriver UDF Release Webdriver Wiki FAQs
MJ36 Posted October 29, 2018 Author Posted October 29, 2018 (edited) it makes sense, it starts to brighten up what if I have a few buttons there Additional question possibly if I can find a button by name in some way. Such knowledge would be useful in the future For example, I mean identification after this Edited October 29, 2018 by MJ36
Danp2 Posted October 29, 2018 Posted October 29, 2018 Use the index like I mentioned above or loop through the collection for some unique value, such a the innerText value. Latest Webdriver UDF Release Webdriver Wiki FAQs
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