Closed systestrjr closed 6 years ago
MsUia::Control#click is written to click until a condition is met. This condition can be passed to the method as a block or you can rely on the default condition of 'the thing that I clicked on is gone'. The default condition of the control going away is fine for things like a close button or a menu item that will go away afterward but sometimes (okay, a LOT of the time) the thing that you want to click will not be going anywhere. In these cases, you'll want to pass in a block so that RAutomation knows when to stop clicking the control.
If all you want to do is click something one time then this should do the trick:
element.click{ true }
Aside from a wiki update, can we call this one closed?
Is the block version of click
even needed for MsUia
adapter? I remember that it was needed for Win32
and AutoIt
adapter because they sent a click message to the control, which might have been dismissed by Windows. Doesn't MsUia
use some other method, which isn't that flaky? @leviwilson isn't that the case?
It's not needed for the MsUia
version. #click
should use Invoke directly from UI Automation.
Waiting for a change in MsUia adapter. @leviwilson will you have time to do these changes some time in the future?
Closing this due to inactivity.
First post....coming from watir world.
Our automation suite is expanding to support automating our WPF applications...
C:\Temp\rauto>gem list |grep ffi ffi (1.9.6) C:\Temp\rauto>gem list |grep rautomation rautomation (0.17.0) C:\Temp\rauto>ruby -v ruby 1.9.3p550 (2014-10-27) [i386-mingw32] Inspect Tool: v7.0.0.0 (win7sp1_gdr.110826-1504)
First time going through the 'absolute beginners guide' (using mspaint example) https://github.com/jarmo/RAutomation/wiki/Absolute-Beginner's-Guide
irb code: require 'rautomation' ENV["RAUTOMATION_ADAPTER"] = 'ms_uia' system(start mspaint) pw = RAutomation::Window.new :title => /Paint/ pw.exists? pw.visible? pw.controls.count ;#not sure what to do with this yet => 26 pw.controls.each {|c| p c.value} ;#control_name or control_type dont seem to work => ... pw.buttons.count ;#these are the '-' and '+' buttons at the bottom of that page => 2 pw.button[1].click ;#click '+' => clicks multiple times until it reaches 800%
I also tried to 'limit' it to 1 click but to no avail 1.times { pw.buttons[1].click } => clicks multiple times until it reaches 800%
(Also I know that wiki says 'To be continued'... so I'm asking nicely - if its not too much to ask - can you PLEASE include examples on how to interact with MSPAINT tab, toolbar, pulldown, menu, etc...)