Page 1 of 1

How To Minimize Automation effort on controls which are ...

Posted: Thu Feb 15, 2018 12:42 pm
by _KK_
How To Minimize Automation effort on controls which are tested against WPF attribute "visible" or "enabled" with parameter "true" or "false"

There is a bunch of controls, e.g. 16 pieces. They are located on one page of the UI, the order is like a Matrix.
They have AutomationId glued, also the Window has an AutomationId so that the controls can be found easiyl.

The WPFP controls are configured with Attributes to enable/disable or show/hide them with extra steering buttons.


First approach in a TestSuite could be (maximum of entries in Ranorex repo for XPathes)


Click event to XPath

Code: Select all

.//form[@automationid='Test']/button[@automationid='CommandButton2' and @visible='False']
Action to change the behavior of the control so that it will be visible (with the extra steering button)

Click event to XPath

Code: Select all

.//form[@automationid='Test']/button[@automationid='CommandButton2' and @visible='True']
Revert behavior with steering button so that control will be hidden

Click event to XPath

Code: Select all

.//form[@automationid='Test']/button[@automationid='CommandButton2' and @visible='False']

Second approach could be using "UserMethods"
Third method could be use DataDriven Testing with csv files


Thanks in advance for any hint.

BR

Klaus

Re: How To Minimize Automation effort on controls which are ...

Posted: Fri Feb 16, 2018 12:26 pm
by _KK_
I grabbed a solution at least with the help of Pavel!

DDT Approach.

Using XPath with a * (asterisk) as wildcard for Ranorex-Adapter:

Code: Select all

.//form[@automationid='AID-Test']/*[@automationid=$AutomationId and @visible=$visible]
csv-file for DDT looks like

Code: Select all

AutomationId,visible
CommandButton1,true
DataControl1,true
BarControl2,false
TextControl5,false

Re: How To Minimize Automation effort on controls which are ...

Posted: Fri Feb 16, 2018 8:44 pm
by Vega
I too like the data driven approach as you can also validate against the expected visible state. There is a less optimal approach and may not even work for your scenario, but if you only care about finding the objects and then performing actions upon it, you could just make your path more generic:

Code: Select all

.//form[@automationid='Test']/button[@automationid='CommandButton2'] //We do not care if it is visible or not
.//form[@automationid='Test']/button[@automationid='CommandButton2' and @visible='False' or @visible='True] //Essentially the same thing as above since visible is a boolean
then once you find the object, you can validate it. As mentioned before, I would recommend doing the data driven approach because it allows you to easily validate the expected state.