Click on a tab in a ribbon with a WinForms app using DevExpress controls

Best practices, code snippets for common functionality, examples, and guidelines.
User avatar
jmarkman
Posts: 4
Joined: Mon Sep 10, 2018 4:12 pm

Click on a tab in a ribbon with a WinForms app using DevExpress controls

Post by jmarkman » Mon Sep 10, 2018 7:09 pm

In the limited amount of time I have with the trial, I'm trying to write some simple automation in Visual Studio following the VS integration guide. I'm not changing a whole lot from the calculator example, but I'm having trouble specifying a type for FindSingle to click on a button in a ribbon control. My first instinct was to do something like
var ribbonControl = myApp.FindSingle<Ribbon>
but it appears that this isn't a feature.

So instead, I'm trying
Form myApp = Host.Local.FindSingle($"form[@processname='{processName}']");
var mainWindow = myApp.FindSingle("form[@controlname='MainGForm']");
var ribbonControl = mainWindow.FindSingle(@"./element[@controlname='ribbonControl1']");
var toolsTab = ribbonControl.FindSingle(@".//tabpage[@accessiblename='Tools']");
toolsTab.Click();
but intellisense says that there's no Click() method for the tools tab, though according to Ranorex Spy, I'm already at the deepest node in the path. The example program in the VS doc gets to actually leverage the generic version of FindSingle, but what is my course of action for clicking on this item?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Click on a tab in a ribbon with a WinForms app using DevExpress controls

Post by odklizec » Thu Sep 13, 2018 8:27 am

Hi,

You must either specify the control type, or use "Unknown" to be able to use "click" action.

Code: Select all

TabPage toolsTab = ribbonControl.FindSingle(@".//tabpage[@accessiblename='Tools']");  
or 
Unknown toolsTab = ribbonControl.FindSingle(@".//tabpage[@accessiblename='Tools']");  
toolsTab.Click();  
Hope this helps?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
jmarkman
Posts: 4
Joined: Mon Sep 10, 2018 4:12 pm

Re: Click on a tab in a ribbon with a WinForms app using DevExpress controls

Post by jmarkman » Mon Sep 17, 2018 3:33 pm

This does help, actually. Thank you!

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Click on a tab in a ribbon with a WinForms app using DevExpress controls

Post by odklizec » Tue Sep 18, 2018 9:18 am

Hi,

I'm glad it helped ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration