Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF UI Automation with Caliburn.Micro?
    primarykey
    data
    text
    <p>I am attempting to write some UI automation tests for a WPF application that is using <a href="http://caliburnmicro.codeplex.com" rel="nofollow">Caliburn.Micro</a> and <a href="http://white.codeplex.com/" rel="nofollow">White</a>. I am using CM's builtin conventions to bind my controls to the view model's properties and methods. I am also using <code>Conductor</code> classes so that I may have multiple views visible on a single screen. This generally means that multiple controls on a screen can end up having the same <code>x:Name</code> value. It will just get bound to a different view model. A good idea of what I am trying to do can be seen in the <a href="http://caliburnmicro.codeplex.com/SourceControl/changeset/view/ff8f27cb3fb0#" rel="nofollow">HelloScreens sample application that comes with CM</a>.</p> <p>The problem that I am running in to is that I will have multiple XAML elements with the same <code>x:Name</code> attribute so that CM can handle all of the binding work for me. This unfortunately means that multiple <code>UIItem</code> objects will have the same UI Automation ID. The only way I have found to get, for instance, different <code>TextBlock</code> elements with <code>x:Name="DisplayName"</code> is to make a call such as the following:</p> <pre><code>SearchCriteria criteria = SearchCriteria.ByAutomationId("DisplayName").AndIndex(1); WPFLabel label = myWindow.Get&lt;WPFLabel&gt;(criteria); </code></pre> <p>This means my tests need to know the exact order that different controls are placed on the screen, which seems very brittle. I can see my tests all breaking just by adding another view model.</p> <ul> <li>Is there a way to specify the Automation ID other than using the <code>x:Name</code> attribute?</li> <li>Would this be easier if I used the UI Automation framework directly instead of using White?</li> <li>Or, do I really have to forego CM's convention based binding and give everyting unique <code>x:Name</code> values and bind them by hand?</li> </ul> <p><strong>UPDATED</strong></p> <p>To clarify what I mean by having multiple views visible at once, here is my general layout. I have my <code>ShellViewModel</code> which I derive from <code>Conductor&lt;IScreen&gt;.Collection.OneActive</code>. Then my view has an <code>ItemsControl</code> that is bound to the shell view model's <code>Items</code> property. Each item template shows a button that is meant to load that specific <code>IScreen</code> into a <code>ContentControl</code> that is on the shell's view. So, If I try to look for an element with <code>x:Name="DisplayName"</code>, I have the label on the shell view, the label on the button in the <code>ItemsControl</code> as well as a label inside of the <code>ContentControl</code>. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload