How to use screen repository

Apr 23, 2010 at 8:04 AM


To learn about White, I am trying to create a very simple test where I launch Calculator, and perform the operation 2 x 3

I used recorder and created this class:

//CalculatorMain.cs  (this is the main screen repository class)  

using White.Core.UIItems;

using White.Core.UIItems.WindowItems;

using Repository;


public partial class Calculator : Repository.AppScreen   


private White.Core.UIItems.Button Multiply = null ;  

private White.Core.UIItems.Button Three = null;    

private White.Core.UIItems.Button Two = null;

    protected Calculator() { }    public Calculator(White.Core.UIItems.WindowItems.Window window, Repository.ScreenRepository screenRepository) :             base(window, screenRepository)            {

    public virtual void multiply()  









The Other class is Test.cs that contains the main function:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using White.Core;

using White.Core.UIItems.WindowItems;

using White.Core.Factory;

using White.NUnit;

using Repository;

using White.Core.UIItems;

namespace CalculatorMain{
    class Test    {      

        public static void Main()      

 {         Application application = Application.Launch("C:\\Windows\\System32\\calc.exe");          

   ScreenRepository screenRepository = new ScreenRepository(application.ApplicationSession);          

  Window window = application.GetWindow("Calculator", InitializeOption.WithCache);

                         Calculator c = new Calculator(window, screenRepository);                        





ScreenRepository as the name suggests is the repository of the screens. All the screens should be retrieved from it. ScreenRepository is initialized for a particular application. When asked for a window it internally calls the application to find the window and creates a screen object. But before returning it to the caller it initialized all the fields in the screen class. (The screen class, as shown above, consists of all the UIItems present in the window).

The initialization of field in screen class works on the name of the field and the type of the UIItem defined.
e.g. for a field defined like this:
private WinFormTextBox nameTextBox = null;
ScreenRepository would find it by, calling window.Get<TextBox>("nameTextBox");"


Technically, When i call Calculator c = new Calculator(window, screenRepository), the buttons in calculator c instance should automatically initialize according to the statement above. This is not happening. The function c.multiply() is throwing exceptions because the buttons are still null...

Can someone guide me on how to use screenrepositories?






May 18, 2010 at 4:57 AM

Dec 22, 2010 at 4:58 PM



I tried the same thing but output is not the same 

instead I get 

2.Click();2, .BulkText = "2,";*.Click();2, .BulkText = "2,";3.Click();3, .BulkText = "3,";

and here is my class

using White.Core.UIItems;using White.Core.UIItems.WindowItems;using Repository;public partial class Calculator : Repository.AppScreen {    private White.Core.UIItems.WindowStripControls.MenuBar Application;    [Repository.ScreenAttributes.AutomationIdAttribute("3, ")]    private White.Core.UIItems.TextBox 3;    private White.Core.UIItems.Button Backspace;    private White.Core.UIItems.Button CE;    private White.Core.UIItems.Button C;    [Repository.ScreenAttributes.IndexAttribute("0", 0)]    private White.Core.UIItems.Label 0;    private White.Core.UIItems.Button MC;    private White.Core.UIItems.Button 7;    private White.Core.UIItems.Button 8;    private White.Core.UIItems.Button 9;    [Repository.ScreenAttributes.AutomationIdAttribute("/")]    private White.Core.UIItems.Button ;    private White.Core.UIItems.Button sqt;    private White.Core.UIItems.Button MR;    private White.Core.UIItems.Button 4;    private White.Core.UIItems.Button 5;    private White.Core.UIItems.Button 6;    [Repository.ScreenAttributes.AutomationIdAttribute("*")]    private White.Core.UIItems.Button ;    [Repository.ScreenAttributes.AutomationIdAttribute("%")]    private White.Core.UIItems.Button ;    private White.Core.UIItems.Button MS;    private White.Core.UIItems.Button 1;    private White.Core.UIItems.Button 2;    private White.Core.UIItems.Button 3;    private White.Core.UIItems.Button -;    [Repository.ScreenAttributes.AutomationIdAttribute("1/x")]    private White.Core.UIItems.Button 1x;    [Repository.ScreenAttributes.AutomationIdAttribute("M+")]    private White.Core.UIItems.Button M;    private White.Core.UIItems.Button 0;    [Repository.ScreenAttributes.AutomationIdAttribute("+/-")]    private White.Core.UIItems.Button -;    [Repository.ScreenAttributes.AutomationIdAttribute(".")]    private White.Core.UIItems.Button ;    [Repository.ScreenAttributes.AutomationIdAttribute("+")]    private White.Core.UIItems.Button ;    [Repository.ScreenAttributes.AutomationIdAttribute("=")]    private White.Core.UIItems.Button ;    [Repository.ScreenAttributes.IndexAttribute("1", 1)]    private White.Core.UIItems.Label 1;    protected Calculator() {    }    public Calculator(White.Core.UIItems.WindowItems.Window window, Repository.ScreenRepository screenRepository) :             base(window, screenRepository) {    }}

of course it cannot compile. I am missing any option? I d/l my code from google repo

Dec 22, 2010 at 5:35 PM

nevermind probably confused by Rafioso's code. I believe the answer to my question lies here