1

I am using White Framework for automation. when I trying to get desktop instance I got exception "The type initializer for 'White.Core.Desktop' threw an exception."

My code looks like :

var window = White.Core.Desktop.Instance.Windows().Find(obj => obj.Title.Contains("TestAppHome"));

Is there any way to capture the window without exception that is without using White.Core.Desktop class?

Any help would be greatly appreciated !

drets
  • 2,583
  • 2
  • 24
  • 38
S.Roshanth
  • 1,499
  • 3
  • 25
  • 36

2 Answers2

0

Try this one:

List<White.Core.UIItems.WindowItems.Window> windows = WindowFactory.Desktop.DesktopWindows();
var window = windows.Find(w => w.Title.Contains("TestAppHome"));
drets
  • 2,583
  • 2
  • 24
  • 38
  • Even both method working fine within Visual Studio,when I try to run the white test outside the Visual Studio I got exception for both methods.The exception is `The type initializer for 'TestStack.White.Desktop' threw an exception.System.TypeInitializationException` `Operation timed out. (Exception from HRESULT: 0x80131505) System.Runtime.InteropServices.COMException` do you know any solutions for this issue? Because of this issue I am unable to run the White test outside the Visual studio. – S.Roshanth Apr 08 '14 at 12:35
  • Nope, just for info: http://msdn.microsoft.com/en-US/library/af1y26ew(v=vs.80).aspx – drets Apr 08 '14 at 13:30
  • ok,thanks. This link describes my actual problem : http://white.codeplex.com/workitem/7475 – S.Roshanth Apr 09 '14 at 04:57
  • Fabulous, Roshan_Rokey! – drets Apr 09 '14 at 05:38
  • bro,Does White framework needs active window to run the test? since Coded UI needs active window I am doubt in White as well. – S.Roshanth Apr 17 '14 at 06:18
0

Try this. You can directly launch the target application and get it's UI elements rather than search all UI elements in Desktop. I think this is very efficient.

static void Main(string[] args) {

        Application app = Application.Launch(@"C:\Testing\Sample.txt");  //Target application 
        var appWindow = app.GetWindow("Sample - Notepad");
        appWindow.RightClick();
        PopUpMenu popupMenu = appWindow.Popup;
        var saveOptionMenuItem = popupMenu.ItemBy(SearchCriteria.ByText("Open IME"));
        saveOptionMenuItem.Click();

    }