var navigator = BonusAppControllers.EbsControl.CurrentApp.GetWindow("XWindow").Get(SearchCriteria.ByAutomationId("AnimatedExplorerNavigator"));
AutomationElement dashboardElement = navigator.AutomationElement.FindFirst(TreeScope.Subtree,SearchConditionFactory.CreateForName("NavigateLink_1").AutomationCondition);
var dashBoardBtn = new Button(dashboardElement, navigator.ActionListener);
dashBoardBtn.Click();
I have this code for the button with Name as NavigateLink_1. Now when i run this and debug it, I find that I am able to get the correct button instance in the dashBoardBtn variable but the Click() function isn't working. Even if i try to do all this just by using the button name as in using Get(SearchCriteria.ByText("NavigateLink_1")) I face the same problem. The same thing I tried with some other button part of the same group of buttons but it's working fine in that case.
Can Anyone suggest me what could be the problem.I am using the White Framework and UI Spy as the UI inspector for my application
I haven't used White, but I have used the native UIA libraries. The issue you'll occasionally run into with it is that you'll have an object that is clickable, but depending on how the click is being handled internally, you may not necessarily be able to use the InvokePattern to perform a click. That might be the case here.
As an alternative, you can use some code to move the mouse cursor over the AutomationElement and issue a click using P/Invoke. It's a bit of a hack, but it's often the simplest option when you run into this problem.