{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","params":[],"results":{"codes":[]}},"next":{"description":"","pages":[]},"title":"Getting Started with White","type":"basic","slug":"getting-started","excerpt":"","body":"### Pre-requisites\n.NET 4.0 framework\n\n## Getting Started\n1. Install via NuGet \n`install-package TestStack.White`\n2. Have a look at the [WPF](https://github.com/TestStack/White/tree/master/src/Sample%20App/Wpf) or [WinForms](https://github.com/TestStack/White/tree/master/src/Sample%20App/WinForms) sample projects\n3. Have a look at Whites UI Tests, White has automated tests for most controls to prevent regressions in the codebase. These serve as a great example of how to automate different controls. See [White's UI Tests](https://github.com/TestStack/White/tree/master/src/TestStack.White.UITests/ControlTests)\n4. Download [http://uiautomationverify.codeplex.com/](http://uiautomationverify.codeplex.com/) which is an ESSENTIAL tool when doing UI Automation work.\n5. Start writing tests, first off you require a unit testing framework like xUnit or nUnit. See below for a basic walkthrough\n6. Join the mailing list at [https://groups.google.com/forum/#!forum/teststack_white](https://groups.google.com/forum/#!forum/teststack_white)\n7. Report issues at [https://github.com/TestStack/White/issues?state=open](https://github.com/TestStack/White/issues?state=open)\n8. If you would like to contribute back, read [Contributing](/Contributing.html) to learn how to get started contributing back!\n\n## Writing your first test\n\n### Start off with an empty test stub\n\nIn *MSTest*:\n\n``` csharp\n[TestClass]\npublic class MyTests\n{\n [TestMethod]\n public void MyFirstUITest()\n {\n }\n}\n```\n\nIn *NUnit*:\n\n``` csharp\n[TestFixture]\npublic class MyTests\n{\n [Test]\n public void MyFirstUITest()\n {\n }\n}\n```\n\nIn *xUnit*:\n\n``` csharp\npublic class MyTests\n{\n [Fact]\n public void MyFirstUITest()\n {\n }\n}\n```\n\n### Get hold of a window\nFirst you need to determine the correct path of the application you want to test. \n\nIn *MSTest*: \n``` csharp\nvar applicationDirectory = TestContext.TestDeploymentDir;\n```\n\nIn *NUnit*: \n``` csharp\nvar applicationDirectory = TestContext.CurrentContext.TestDirectory;\n```\n\nThen you create a new instance of your application\n``` csharp\nvar applicationPath = Path.Combine(applicationPath, \"foo.exe\");\nApplication application = Application.Launch(applicationPath); \nWindow window = application.GetWindow(\"bar\", InitializeOption.NoCache);\n```\n\nWhite uses the UI Automation API (UIA) to find controls on a window. UIA communicates to a displayed window via window messages. This find is performed by iterating through all the controls in a window.\n\n### Finding a UI Item and performing action\n``` csharp\nButton button = window.Get<Button>(\"save\");\nbutton.Click();\n```\n\n### Finding a UIItem based on SearchCriteria\n``` csharp\n SearchCriteria searchCriteria = SearchCriteria\n \t.ByAutomationId(\"name\")\n \t.AndControlType(typeof(TextBox))\n \t.AndIndex(2);\n TextBox textBox = (TextBox) window.Get(searchCriteria);\n textBox.Text = \"Anil\";\n```","updates":["5550d56f00420e0d00d1319b"],"order":1,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"54d2994a2ce0e00d0075159c","user":"54c4ca1473b3db0d001a7571","version":{"version":"1.0","version_clean":"1.0.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["54d299492ce0e00d0075159a"],"_id":"54d299492ce0e00d00751599","project":"54d299482ce0e00d00751596","releaseDate":"2015-02-04T22:12:25.351Z","__v":1,"createdAt":"2015-02-04T22:12:25.351Z"},"__v":5,"category":{"sync":{"isSync":false,"url":""},"pages":["54d2994a2ce0e00d0075159c","54d91797ea2a7d0d002a5ab2","5551bb13bcb05a0d00693109"],"title":"Documentation","slug":"documentation","order":9999,"from_sync":false,"reference":false,"_id":"54d299492ce0e00d0075159a","version":"54d299492ce0e00d00751599","createdAt":"2015-02-04T22:12:25.857Z","project":"54d299482ce0e00d00751596","__v":3},"createdAt":"2015-02-04T22:12:26.607Z","project":"54d299482ce0e00d00751596","githubsync":""}