Open up the package manager console and enter the following:
PM> Install-Package AFrame.Web
In this particular test we are verifying that google's homepage contains a button with the text 'Google Search'
using AFrame.Web;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace UnitTestProject1
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void GoogleHomepageShouldContainSearchButton()
{
using(var context = new WebContext(new OpenQA.Selenium.Firefox.FirefoxDriver()))
{
//Arrange
var homepage = context.NavigateTo("https://www.google.com");
//Act
var searchBtn = homepage.CreateControl("button:contains('Google Search')"); //jQuery selectors!
//Assert
Assert.IsTrue(searchBtn.Exists);
}
}
}
}
Open up the package manager console and enter the following:
PM> Install-Package AFrame.Desktop
In this particular test we are verifying that two plus two equals four with the Microsoft's inbuilt calculator
using AFrame.Desktop;
using AFrame.Desktop.Controls.Win;
using Microsoft.VisualStudio.TestTools.UITesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace UnitTestProject1
{
[CodedUITest]
public class UnitTest1
{
[TestMethod]
public void TwoPlusTwoEqualsFour()
{
using(var context = new DesktopContext())
{
//Arrange
var calculator = context.Launch<WinWindow>(@"C:\Windows\system32\calc.exe");
calculator.SearchProperties.Add(WinWindow.PropertyNames.Name, "Calculator");
var twoBtn = calculator.CreateControl<WinButton>("2");
var plusBtn = calculator.CreateControl<WinButton>("Add");
var equalsBtn = calculator.CreateControl<WinButton>("Equals");
var resultTxt = calculator.CreateControl<WinText>("Result");
//Act
twoBtn.Click();
plusBtn.Click();
twoBtn.Click();
equalsBtn.Click();
//Assert
Assert.AreEqual("4", resultTxt.DisplayText);
}
}
}
}