5ervant Posted May 4, 2017 Posted May 4, 2017 (edited) Go create a quick account in Zapier and go to https://zapier.com/app/dashboard and make some Zaps! Just need to click the specific instance of an .open-menu button and then click its a.run (anchor) element. Doing this IE.au3 script just causing to click its container element: $target = 1; Target the first instance #include <IE.au3> $oIE = _IEAttach("Dashboard - Zapier") $count = 0; $tags = _IETagNameGetCollection($oIE, "div") For $tag in $tags $class_value = $tag.GetAttribute("class") If $class_value = "open-menu" Then $count += 1 if $count = $target Then MsgBox(0, "Instance: ", $count) ; $tag.fireEvent("onmousedown") ; _IEAction($tag, "click") ; $tag.fireEvent("onmouseup") ; Or this but not working ; $tag.Click EndIf EndIf Next I also tried to do it using FF.au3 $target = 1; Target the first instance #Include <Array.au3> #Include <FF.au3> $count = 0; If _FFConnect(Default, Default, 3000) Then $aArray = _FFXPath( "//div[@class='open-menu']", "", 7 ) ; _ArrayDisplay($aArray) For $tag in $aArray $count += 1 if $count = $target Then MsgBox(0, "Instance: ", $count) _FFClick($tag) EndIf Next EndIf Error: _FFClick ==> No match: $sElement: [number] Could some help me how to click such buttons on such kind of a dynamic page? Edited May 5, 2017 by 5ervant
5ervant Posted May 4, 2017 Author Posted May 4, 2017 No one can guess? So that means, such kind of dynamic button can't be click using IE.au3 or FF.au3 ..
Danp2 Posted May 5, 2017 Posted May 5, 2017 You have to examine the underlying event code to be able to figure out how to trigger the menu. In this case, there's a single event on the main container that is used for each of the objects within that container. The event looks at the position of the click to determine which element to actually trigger. Here's some code that will cause the menu to appear -- #Include <FF.au3> If _FFConnect(Default, Default, 3000) Then _FFXPath( "//div[@class='open-menu']") If @error = $_FF_ERROR_Success Then $pos = _FFCmd('FFau3.xpath.getBoundingClientRect().x') + 1 $cmd = "d=FFau3.WCD.createEvent('MouseEvent');d.initMouseEvent('click',true,true,window,0,0,0," & $pos & ",0,0,0,0,0,0,null);FFau3.xpath.parentNode.parentNode.parentNode.dispatchEvent(d);" _FFCmd($cmd) EndIf EndIf It creates a click event with the proper positioning value and then passes it to the container element to be processed. 5ervant 1 Latest Webdriver UDF Release Webdriver Wiki FAQs
5ervant Posted May 5, 2017 Author Posted May 5, 2017 7 hours ago, Danp2 said: You have to examine the underlying event code to be able to figure out how to trigger the menu. In this case, there's a single event on the main container that is used for each of the objects within that container. The event looks at the position of the click to determine which element to actually trigger. Here's some code that will cause the menu to appear -- #Include <FF.au3> If _FFConnect(Default, Default, 3000) Then _FFXPath( "//div[@class='open-menu']") If @error = $_FF_ERROR_Success Then $pos = _FFCmd('FFau3.xpath.getBoundingClientRect().x') + 1 $cmd = "d=FFau3.WCD.createEvent('MouseEvent');d.initMouseEvent('click',true,true,window,0,0,0," & $pos & ",0,0,0,0,0,0,null);FFau3.xpath.parentNode.parentNode.parentNode.dispatchEvent(d);" _FFCmd($cmd) EndIf EndIf It creates a click event with the proper positioning value and then passes it to the container element to be processed. Thanks, it would be great if you can show a IE.au3 version of that 'cause that FF.au3 version is hard to understand, just for educational purpose..
Danp2 Posted May 5, 2017 Posted May 5, 2017 2 hours ago, 5ervant said: Thanks, it would be great if you can show a IE.au3 version of that 'cause that FF.au3 version is hard to understand, just for educational purpose.. Sorry, but your on your own there. :-) Suggest that you search to forum for a solution. IIRC, there's a post by DaleHolm that addresses a similar issue. Latest Webdriver UDF Release Webdriver Wiki FAQs
Subz Posted May 5, 2017 Posted May 5, 2017 Could try: #RequireAdmin #include <IE.au3> $oIE = _IECreate("https://zapier.com/app/dashboard", 1) $oDivs = _IETagNameGetCollection($oIE, "div") For $oDiv in $oDivs If $oDiv.ClassName = "open-menu" Then $hWnd = _IEPropertyGet($oIE, "hWnd") ControlClick($hWnd, "", "", "left", 1, _IEPropertyGet($oDiv, "browserx") + 2, _IEPropertyGet($oDiv, "browsery") + 2) ExitLoop EndIf Next
Danp2 Posted May 5, 2017 Posted May 5, 2017 This is the original thread I was referring to, which uses a solution similar to @Subz. Latest Webdriver UDF Release Webdriver Wiki FAQs
5ervant Posted May 10, 2017 Author Posted May 10, 2017 On 5/5/2017 at 8:34 AM, Danp2 said: You have to examine the underlying event code to be able to figure out how to trigger the menu. In this case, there's a single event on the main container that is used for each of the objects within that container. The event looks at the position of the click to determine which element to actually trigger. Here's some code that will cause the menu to appear -- #Include <FF.au3> If _FFConnect(Default, Default, 3000) Then _FFXPath( "//div[@class='open-menu']") If @error = $_FF_ERROR_Success Then $pos = _FFCmd('FFau3.xpath.getBoundingClientRect().x') + 1 $cmd = "d=FFau3.WCD.createEvent('MouseEvent');d.initMouseEvent('click',true,true,window,0,0,0," & $pos & ",0,0,0,0,0,0,null);FFau3.xpath.parentNode.parentNode.parentNode.dispatchEvent(d);" _FFCmd($cmd) EndIf EndIf It creates a click event with the proper positioning value and then passes it to the container element to be processed. Can you give me another twick of that, that will click let say, the second button? 'Cause @Subz solution isn't that nice, will require you to activate the window before working.. And upon a quick testing, no @DaleHohm solution work and still, a ControlClick() .
Danp2 Posted May 10, 2017 Posted May 10, 2017 You need to change the _FFXPath command to grab the desired element. How would you change this line _FFXPath( "//div[@class='open-menu']") so that it grabs the 2nd instance of a matching div? Latest Webdriver UDF Release Webdriver Wiki FAQs
5ervant Posted May 10, 2017 Author Posted May 10, 2017 (//div[@class='open-menu'])[2] A hour spent.. Danp2 1
Danp2 Posted May 10, 2017 Posted May 10, 2017 Congrats on finding the solution on your own! If you check the online help for _FFXPath, you'll find another example using position(). 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