Core.Factory.UIItemSearchException : Could not find UIItem with, AutomationId=WixUI_Bmp_Banner,ControlType=ControlType.Edit,Index=0,Index=0

Jan 29, 2009 at 8:21 AM
Hi.

White-bin-11-9-2008

I am trying to automate the testing of a wix v3 setup installer, but am having a problem with one particular dialog.

Here is the window class generated from Recorder.exe:

using Core.UIItems;
using Core.UIItems.WindowItems;
using Repository;
public partial class Setup_SQL : Repository.AppScreen {
    [Repository.ScreenAttributes.AutomationIdAttribute("WixUI_Bmp_Banner")]
    private Core.UIItems.Image WixUIBmpBanner;
    [Repository.ScreenAttributes.IndexAttribute("SQLDatabaseServerWindowsAuthentication0", 0)]
    [Repository.ScreenAttributes.AutomationIdAttribute("SQL Database Server Windows Authentication")]
    private Core.UIItems.Label SQLDatabaseServerWindowsAuthentication0;
    [Repository.ScreenAttributes.AutomationIdAttribute("Enter the credentials with Administrator privileges for the SQL Database Server.")]
    private Core.UIItems.Label EnterthecredentialswithAdministratorprivilegesfortheSQLDatabaseServer;
    [Repository.ScreenAttributes.IndexAttribute("SQLDatabaseServerWindowsAuthentication1", 1)]
    [Repository.ScreenAttributes.AutomationIdAttribute("SQL Database Server Windows Authentication")]
    private Core.UIItems.Label SQLDatabaseServerWindowsAuthentication1;
    [Repository.ScreenAttributes.AutomationIdAttribute("Domain:")]
    private Core.UIItems.Label Domain;
    [Repository.ScreenAttributes.IndexAttribute("WixUIBmpBanner0", 0)]
    [Repository.ScreenAttributes.AutomationIdAttribute("WixUI_Bmp_Banner")]
    private Core.UIItems.TextBox WixUIBmpBanner0;
    [Repository.ScreenAttributes.IndexAttribute("WixUIBmpBanner1", 1)]
    [Repository.ScreenAttributes.AutomationIdAttribute("WixUI_Bmp_Banner")]
    private Core.UIItems.TextBox WixUIBmpBanner1;
    [Repository.ScreenAttributes.AutomationIdAttribute("Username:")]
    private Core.UIItems.Label Username;
    [Repository.ScreenAttributes.IndexAttribute("WixUIBmpBanner2", 2)]
    [Repository.ScreenAttributes.AutomationIdAttribute("WixUI_Bmp_Banner")]
    private Core.UIItems.TextBox WixUIBmpBanner2;
    [Repository.ScreenAttributes.AutomationIdAttribute("Password:")]
    private Core.UIItems.Label Password;
    private Core.UIItems.Label ;
    private Core.UIItems.Button Back;
    private Core.UIItems.Button Next;
    private Core.UIItems.Button Cancel;
    protected Setup_SQL() {
    }
    public Setup_SQL(Core.UIItems.WindowItems.Window window, Repository.ScreenRepository screenRepository) :
            base(window, screenRepository) {
    }
}

Here is the window class fixed to prevent compiler errors and with the LogStructure method:

using Core.UIItems;
using Core.UIItems.WindowItems;
using Repository;
using Repository.ScreenAttributes;
public partial class Setup_SQL : Repository.AppScreen {
    [Repository.ScreenAttributes.AutomationIdAttribute("WixUI_Bmp_Banner")]
    private Core.UIItems.Image WixUIBmpBanner;
    [Repository.ScreenAttributes.IndexAttribute(0)]
    [Repository.ScreenAttributes.AutomationIdAttribute("SQL Database Server Windows Authentication")]
    private Core.UIItems.Label SQLDatabaseServerWindowsAuthentication0;
    [Repository.ScreenAttributes.AutomationIdAttribute("Enter the credentials with Administrator privileges for the SQL Database Server.")]
    private Core.UIItems.Label EnterthecredentialswithAdministratorprivilegesfortheSQLDatabaseServer;
    [Repository.ScreenAttributes.IndexAttribute(1)]
    [Repository.ScreenAttributes.AutomationIdAttribute("SQL Database Server Windows Authentication")]
    private Core.UIItems.Label SQLDatabaseServerWindowsAuthentication1;
    [Repository.ScreenAttributes.AutomationIdAttribute("Domain:")]
    private Core.UIItems.Label Domain;
    [Repository.ScreenAttributes.IndexAttribute(0)]
    [Repository.ScreenAttributes.AutomationIdAttribute("WixUI_Bmp_Banner")]
    public Core.UIItems.TextBox WixUIBmpBanner0;
    [Repository.ScreenAttributes.IndexAttribute(1)]
    [Repository.ScreenAttributes.AutomationIdAttribute("WixUI_Bmp_Banner")]
    public Core.UIItems.TextBox WixUIBmpBanner1;
    [Repository.ScreenAttributes.IndexAttribute(2)]
    [Repository.ScreenAttributes.AutomationIdAttribute("WixUI_Bmp_Banner")]
    public Core.UIItems.TextBox WixUIBmpBanner2;
    [Repository.ScreenAttributes.AutomationIdAttribute("Username:")]
    private Core.UIItems.Label Username;
    [Repository.ScreenAttributes.AutomationIdAttribute("Password:")]
    private Core.UIItems.Label Password;
    private Core.UIItems.Button Back;
    [Text("Next")]
    public Core.UIItems.Button Next;
    private Core.UIItems.Button Cancel;
    protected Setup_SQL() {
    }
    public Setup_SQL(Core.UIItems.WindowItems.Window window, Repository.ScreenRepository screenRepository)
        :
            base(window, screenRepository) {
    }
    public virtual void LogStructure()
    {
        base.window.LogStructure();
    }
}


My code looks like this:

Setup_SQL sqlDlg =
                screenRepository.Get<Setup_SQL>(title, InitializeOption.NoCache);

            sqlDlg.LogStructure();
            sqlDlg.WixUIBmpBanner0.Text = ".";
            sqlDlg.WixUIBmpBanner1.Text = "username";
            sqlDlg.WixUIBmpBanner2.Text = "password";
            sqlDlg.Next.Click();

The exception I get is:

Core.Factory.UIItemSearchException : Could not find UIItem with, AutomationId=WixUI_Bmp_Banner,ControlType=ControlType.Edit,Index=0,Index=0
at
d:\white-os\Repository\Interceptors\UIItemInterceptor.cs(36)
at
d:\OSS\Castle\Tools\Castle.DynamicProxy2\Castle.DynamicProxy\AbstractInvocation.cs(165)
at
at TextBoxProxy01a25a9315464bb2bce9b6a1c0d77c16.set_Text(String value)
at
mycode pointing to the line with sqlDlg.WixUIBmpBanner0.Text = ".";

Here is the LogStructure() output:

[2009-01-29 00:01:54,382][INFO ] AutomationId:
ControlType: ControlType.Window
Name: MyProduct
HelpText:
Bounding rectangle: 150,93,499,385
ClassName: MsiDialogCloseClass
IsOffScreen: False

    AutomationId: 777
    ControlType: ControlType.Image
    Name: WixUI_Bmp_Banner
    HelpText:
    Bounding rectangle: 153,115,493,58
    ClassName: Static
    IsOffScreen: False

    AutomationId: 881
    ControlType: ControlType.Edit
    Name: WixUI_Bmp_Banner
    HelpText:
    Bounding rectangle: 267,205,154,20
    ClassName: RichEdit20W
    IsOffScreen: False

    AutomationId: 885
    ControlType: ControlType.Edit
    Name: WixUI_Bmp_Banner
    HelpText:
    Bounding rectangle: 267,240,118,20
    ClassName: RichEdit20W
    IsOffScreen: False

    AutomationId: 886
    ControlType: ControlType.Edit
    Name: WixUI_Bmp_Banner
    HelpText:
    Bounding rectangle: 267,275,117,20
    ClassName: Edit
    IsOffScreen: False

    AutomationId: 771
    ControlType: ControlType.Button
    Name: Back
    HelpText:
    Bounding rectangle: 393,439,74,22
    ClassName: Button
    IsOffScreen: False

    AutomationId: 774
    ControlType: ControlType.Button
    Name: Next
    HelpText:
    Bounding rectangle: 467,439,74,22
    ClassName: Button
    IsOffScreen: False

    AutomationId: 776
    ControlType: ControlType.Button
    Name: Cancel
    HelpText:
    Bounding rectangle: 558,439,74,22
    ClassName: Button
    IsOffScreen: False

    AutomationId: 11
    ControlType: ControlType.Text
    Name: Enter the credentials with Administrator privileges for the SQL Database Server.
    HelpText:
    Bounding rectangle: 186,145,400,20
    ClassName: Static
    IsOffScreen: False

    AutomationId: 136
    ControlType: ControlType.Text
    Name: SQL Database Server Windows Authentication
    HelpText:
    Bounding rectangle: 173,123,266,20
    ClassName: Static
    IsOffScreen: False

    AutomationId: 779
    ControlType: ControlType.Text
    Name: SQL Database Server Windows Authentication
    HelpText:
    Bounding rectangle: 153,173,491,2
    ClassName: Static
    IsOffScreen: False

    AutomationId: 781
    ControlType: ControlType.Text
    Name:
    HelpText:
    Bounding rectangle: 153,427,491,2
    ClassName: Static
    IsOffScreen: False

    AutomationId: 827
    ControlType: ControlType.Text
    Name: Domain:
    HelpText:
    Bounding rectangle: 178,205,66,16
    ClassName: Static
    IsOffScreen: False

    AutomationId: 841
    ControlType: ControlType.Text
    Name: Username:
    HelpText:
    Bounding rectangle: 178,245,61,13
    ClassName: Static
    IsOffScreen: False

    AutomationId: 844
    ControlType: ControlType.Text
    Name: Password:
    HelpText:
    Bounding rectangle: 178,280,56,12
    ClassName: Static
    IsOffScreen: False

    AutomationId: TitleBar
    ControlType: ControlType.TitleBar
    Name: MyProduct
    HelpText:
    Bounding rectangle: 153,96,493,19
    ClassName:
    IsOffScreen: False

        AutomationId: SystemMenuBar
        ControlType: ControlType.MenuBar
        Name: System Menu Bar
        HelpText:
        Bounding rectangle: 153,96,18,18
        ClassName:
        IsOffScreen: False

            AutomationId: Item 1
            ControlType: ControlType.MenuItem
            Name: System
            HelpText:
            Bounding rectangle: 153,96,18,18
            ClassName:
            IsOffScreen: False

        AutomationId: Close
        ControlType: ControlType.Button
        Name: Close
        HelpText:
        Bounding rectangle: 629,96,17,17
        ClassName:
        IsOffScreen: False

I ran UIAVerify and it reports pretty much the same properties as Recorder.exe for those three edit controls
I also ran Au3Info.exe and it reports:
ClassnameNN=RichEdit20W1
ClassnameNN=RichEdit20W2
ClassnameNN=Edit1
using AutoIt, I can use that ClassnameNN as the unique identifier to automate interaction with the control.

Did I change something wrong in the window class generated from Recorder.exe?

Any other ideas?

Thank you.
Jan 29, 2009 at 8:58 AM
The only work-around I've come up with is as follows:

add this to the window class:
    public virtual Window window
    {
        get
        {
            return base.window;
        }
    }

And then use this:

sqlDlg.window.Keyboard.Enter(".");
sqlDlg.window.Keyboard.PressSpecialKey(Core.WindowsAPI.KeyboardInput.SpecialKeys.TAB);
sqlDlg.window.Keyboard.Enter("username");
sqlDlg.window.Keyboard.PressSpecialKey(Core.WindowsAPI.KeyboardInput.SpecialKeys.TAB);
sqlDlg.window.Keyboard.Enter("password");

This works great! ;)