window.MenuBar fails when invoked form nunit

Jun 1, 2009 at 5:05 PM
Edited Jun 1, 2009 at 5:06 PM

 

Hello There,

I have been enjoying playing with white for quite few days now. Its cool.. Thank you so much Vivek and Team. 

I have been able to create Screen Classes and test them from a Console program (initializing them and calling their methods etc), however I am running into a crazy problem. The window.MenuBar function fails when the call is made through NUnit (I tried both GUI and console of NUnit). But the same program runs fine when used as a stand alone program. Here is my class, followed by the exception i get.

public Class MyScreen

{

private readonly Window window;

        private readonly Application application;

        public MyScreen(Application application, params string[] menuPath )

        {

            this.window = application.GetWindow(SearchCriteria.All, InitializeOption.NoCache);

            this.application = application;

            SearchCriteria cr = SearchCriteria.All;

            IUIItem[] items = window.GetMultiple(cr);

            MenuBar menuBar = window.MenuBar;

            Menu level2Menu = menuBar.MenuItem(menuPath);            

            level2Menu.Click();

        }

}

 

 Bricks.BricksException : Error invoking MenuBar.MenuItem

----> Core.Factory.UIItemSearchException : Could not find Menu Name=Persons

 at Bricks.RuntimeFramework.ReflectedObject.Invoke(MethodInfo methodInfo, Object[] arguments)

 at Bricks.DynamicProxy.DynamicProxyInterceptors.Process(IInvocation invocation, InterceptContext interceptedContext)

 at Core.Interceptors.CoreInterceptor.Intercept(IInvocation invocation)

 at Castle.DynamicProxy.AbstractInvocation.Proceed()

 at MenuBarProxy193cb505aeca48e0a5bd0ce14a0804e5.MenuItem(String[] path)

 

 

Coordinator
Jun 2, 2009 at 3:07 AM

May be number 3 here.

http://white.codeplex.com/Wiki/View.aspx?title=Other%20questions

Jun 2, 2009 at 5:04 AM

Thank you Vivek, i will make a check and post back here.

Jun 3, 2009 at 3:26 AM

Yeh..it worked :)

Jun 15, 2009 at 10:35 PM

I ran into this same issue on Windows XP. For various reasons it was inconvenient to use the /nothread option with Nunit (as described here: http://white.codeplex.com/Wiki/View.aspx?title=Other%20questions).

Another workaround is to include the following in your test assembly configuration file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="NUnit">
            <section name="TestRunner"
                     type="System.Configuration.NameValueSectionHandler"/>
        </sectionGroup>
    </configSections>
    <NUnit>
        <TestRunner>
            <!-- Necessary for UI automation performed by White (Windows XP only) -->
            <add key="ApartmentState"
                 value="STA" />
        </TestRunner>
    </NUnit>   
</configuration>