Recognizing elements on a TabControl

Ranorex Studio, Spy, Recorder, and Driver.
anujakulkarni
Posts: 29
Joined: Wed Jan 07, 2009 1:15 pm

Recognizing elements on a TabControl

Post by anujakulkarni » Mon Feb 16, 2009 3:05 pm

Hi,

My application has a GUI developed in .NET. It has a Tabcontrol and the Tabcontrol has several elements on it. I am using The Element Browser in Ranorex Studio (Version 2.0.0) to track the different elements of the GUI and add them to the GlobalRepository

My problem is that Ranorex does track the Tabcontrol, but is unable to track any elemnet in it. So even if I try to track a TextBox or a Button on the Tabcontrol, Ranorex Studio (or Spy) identifies it as the parent TabPageList itself instead of the child elemnt.

Please suggest me how I should go about the same?

Cheers,

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Mon Feb 16, 2009 5:18 pm

We need to know some more information about this tab control, in particular its flavor and its class name. Could you send a snapshot of the application to support_at_ranorex.com?
If you need help in creating the snapshot, please consult the Ranorex Spy documentation:
http://www.ranorex.com/support/user-gui ... html#c2072

Regards,
Alex
Ranorex Support Team

anujakulkarni
Posts: 29
Joined: Wed Jan 07, 2009 1:15 pm

Post by anujakulkarni » Tue Feb 17, 2009 10:08 am

Hi,

Unfortunately I cannot send you the snapshot of the application.
This is the definition of the TabControl and one of the TabItems contained in it:

Code: Select all

<TabControl BorderBrush="#6EC4F2" Grid.Row="0" Margin="20 10 20 0">
                <TabItem Header="Enquiries"> 
I am trying to access elements on the Enquiries TabItem. This TabItem also contains some standard .NET Grids. And the controls I am trying to automate are present on these Grids. Basically all the elements (Tabs, Grids,Buttons, TextBoxes etc.) are created using standard .NET controls and none of them are custom made.

Hope this helps.

Cheers,

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Wed Feb 18, 2009 11:39 am

I made a WPF test application with the WPF TabControl source code you provided and all items on the individual tab pages are identified just fine, including elements in a grid like the UniformGrid.

Are all the controls on the tab pages WPF standard controls? What kind of grid do you use inside the tab page? Could you please post their class names?
What .NET framework version do you have installed?

Regards,
Alex
Ranorex Support Team

anujakulkarni
Posts: 29
Joined: Wed Jan 07, 2009 1:15 pm

Post by anujakulkarni » Wed Feb 18, 2009 12:35 pm

Hi Alex,


All controls are standard WPF controls:

- System.Windows.Controls.Textbox
- System.Windows.Controls.Label
- System.Windows.Controls.Textblock
- System.Windows.Controls.Button
- System.Windows.Controls.ListView

hosted within standard Grid panels (System.Windows.Controls.Grid)

We are using .NET Framework 3.5 SP1

Cheers,

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Wed Feb 18, 2009 1:19 pm

I build a WPF example that's structured exactly like you said: a TabControl with a Grid inside hosting several other WPF controls. RanorexSpy does not have any problems spying the controls in the TabPage. So, I really don't know what the problem could be.

Could you send us a sample application that you can reproduce the error with? Or a Ranorex snapshot of your application? Or at least more details on the TabControl by posting the values in the "Detail" tab in RanorexSpy?

Regards,
Alex
Ranorex Support Team

anujakulkarni
Posts: 29
Joined: Wed Jan 07, 2009 1:15 pm

Post by anujakulkarni » Tue Feb 24, 2009 10:43 am

Hi Alex,

I have sent a mail with a sample application attached as requested by you at [email protected].

Hope to hear from you soon.

Cheers,

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Tue Feb 24, 2009 1:18 pm

I reviewed the sample application and found out that this seems to be a bug in the WPF TabControl when using templates, you need to specify the right “Name” in the ContentPresenter in you MainStyles.xaml TabControl style definition:

Code: Select all

<ContentPresenter Name="PART_SelectedContentHost" ContentSource="SelectedContent" />
For more information visit the following URL:
http://social.msdn.microsoft.com/Forums ... 0799a0cf3/

Regards,
Alex
Ranorex Support Team

anujakulkarni
Posts: 29
Joined: Wed Jan 07, 2009 1:15 pm

Post by anujakulkarni » Tue Feb 24, 2009 2:33 pm

Thank Alex!!

That fixed the problem :D

Cheers,

benny28
Posts: 34
Joined: Thu May 31, 2012 4:48 pm
Location: London
Contact:

Re: Recognizing elements on a TabControl

Post by benny28 » Wed Jun 27, 2012 9:59 am

I came across the same problem with Ranorex Spy unable to see TabControl.

Code: Select all

Name="PART_SelectedContentHost"
did not work for us.

But the following did;

namespace:

Code: Select all

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Code: Select all

<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" />
Hope this helps somebody out there!

e.boyle
Posts: 5
Joined: Wed Jul 11, 2012 12:08 pm

Re: Recognizing elements on a TabControl

Post by e.boyle » Wed Oct 24, 2012 1:50 pm

I am having a similar issue but the assignment of the name did not help. I've a simple test project and I cannot see the buttons inside the tabs.

Code: Select all

<Window x:Class="RanorexFindIssues2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:System="clr-namespace:System;assembly=mscorlib"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <StackPanel>
            <ComboBox Name="SelectedPage">
                <System:Int32>0</System:Int32>
                <System:Int32>1</System:Int32>
            </ComboBox>

            <TabControl x:Name="UnseenTabControl" SelectedIndex="{Binding ElementName=SelectedPage, Path=SelectedItem}" OverridesDefaultStyle="True">
                <TabControl.Template>
                    <ControlTemplate TargetType="{x:Type TabControl}">
                        <ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="0" />
                    </ControlTemplate>
                </TabControl.Template>
                <TabItem x:Name="Page3" Header="Page 3">
                    <Grid>
                        <Button Name="OnPage3">OnPage1</Button>
                    </Grid>
                </TabItem>

                <TabItem x:Name="Page4" Header="Page 4">
                    <Grid>
                        <Button Name="OnPage4" Margin="20">OnPage2</Button>
                        <Expander>
                            <Button Name="InsideExpander2">InsideExpander2</Button>
                        </Expander>
                    </Grid>
                </TabItem>
            </TabControl>
        </StackPanel>
    </Grid>
</Window>
Cannot anyone give some advice or see if this code behaves the same for them.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Recognizing elements on a TabControl

Post by Support Team » Thu Oct 25, 2012 10:18 am

Hello,

I need a little bit more information about your application, you environment and the issue.
Which version of Ranorex do you use? Which .NET Framework is installed on your machine? Please make sure that the .NET Framework 4.0 FULL/Extended version is installed.
Is it possible to get a Rnaorex Snapshot from your application?
Thank you!

Regards,
Bernhard
Ranorex Support Team

e.boyle
Posts: 5
Joined: Wed Jul 11, 2012 12:08 pm

Re: Recognizing elements on a TabControl

Post by e.boyle » Thu Oct 25, 2012 10:42 am

I'm using VS 2010 and targeting .NET 4.0 Full in a 64 bit Win 7 environment. I've tried this with Ranorex 3.3.3. The application that reproduces the problem is basically a new WPF application with the code posted in the previous reply in the MainWindow xaml.

I've attached a snapshot from this app and the app itself. Simply select an index in the combo box. You should see some controls but spy will not be able to see them.

My real aplication is seeing something similar but in it I actually see the contents of the first tab but not the second tab (even when it's visible). I'm hoping resolving the issue in the test app will fix my real app.
You do not have the required permissions to view the files attached to this post.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Recognizing elements on a TabControl

Post by Support Team » Fri Oct 26, 2012 11:51 am

Hi,

Thanks for the application!
I tested it with Inspect and UISpy also and they aren't able to identify the elements in that tab, so this seems to be an issue with your control and the UIAutomation implementation for the control.
Is this a custom control of your company?
Could you ask your developer team if they missed to implement UIA for it?

Regards,
Markus
Ranorex Support Team

e.boyle
Posts: 5
Joined: Wed Jul 11, 2012 12:08 pm

Re: Recognizing elements on a TabControl

Post by e.boyle » Fri Oct 26, 2012 12:06 pm

You can see in my previous post the source for this application - it's using only a couple of standard controls with the template overridden for the standard TabControl.

Please have a look at the code in the previous post and tell me if there is something missing/incorrect about it.

Thanks,
Eamonn