TestStack / White

DEPRECATED - no longer actively maintained
Other
1.02k stars 487 forks source link

UIItemClickEvent not working #314

Open williereed opened 9 years ago

williereed commented 9 years ago

When I run the following code: IUIItem[] iuiArray = window.GetMultiple(SearchCriteria.All); foreach (IUIItem item in iuiArray) { if (item.Name == "QWizard::Button::Next") { item.Click(); item.Click(); } }

It doesn't perform the click. Is this a bug or something I'm doing wrong?

an email from Jake Jinnivan said: I think there might be a bug around this in White. I haven’t been able to get back to White as it will require a bunch of time when I do which I just cannot give at the moment.

maxinfet commented 9 years ago

Can you give me an example of the UI you are attempting to automate? Also what platform is this form WPF, Winforms, Win32 or Silverlight?

dpisanu commented 9 years ago

Coming from WPF here I have had this issue with 3rd Party UI Components where as the Button was stlyed strange or the control resembles a button but was a custom control not supporting or just swallowing the click from UIA. On the IUIItem get the Invoke Pattern.

// Get the Invoke Pattern from the UI Item
object pattern = {IUIItem}.AutomationElement.GetCurrentPattern(System.Windows.Automation.InvokePattern.Pattern);

// Cast the result object: 
var castedPattern = (System.Windows.Automation.InvokePattern)pattern;

// Now invoke the pattern;
castedPattern.Invoke();

That does it at times for me.

maxinfet commented 9 years ago

As dpisanu says custom controls can be retemplated making it impossible to click them or perform other actions on them.I have specifically run into content presenters be retemplated which prevented me from getting child elements.