Skip to content

Instantly share code, notes, and snippets.

@technoscavenger
Created January 2, 2019 06:03
Show Gist options
  • Save technoscavenger/dd3e467673ce2cc0c51956a2d75d6ee3 to your computer and use it in GitHub Desktop.
Save technoscavenger/dd3e467673ce2cc0c51956a2d75d6ee3 to your computer and use it in GitHub Desktop.
Example code to close and open Notepad using WhiteX
using System;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestStack.White;
using TestStack.White.Factory;
using TestStack.White.UIItems.Finders;
using TestStack.White.UIItems.MenuItems;
using TestStack.White.UIItems.WindowItems;
namespace UnitTestProject1
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var applicationName = "notepad.exe";
Application application = Application.Launch(applicationName);
var window = application.GetWindow("Untitled - Notepad");
var menubar = window.MenuBars[1];
var file = menubar.MenuItem("File");
file.Click();
var fx = window.Popup; //submenus are implemented as Popup menu for Notepad
var exitMenuItem = fx.Item("Exit");
exitMenuItem.Click();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment