Skip to content

Commit

Permalink
Merge new unit tests for a 0.3 Beta release
Browse files Browse the repository at this point in the history
  • Loading branch information
timotiusmargo committed Jun 14, 2016
2 parents edba5df + 598ec28 commit 65b460d
Show file tree
Hide file tree
Showing 42 changed files with 930 additions and 17 deletions.
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,32 @@ This Github project provides
- samples
- issue tracking

Videos discussing this project
**Videos about WinAppDriver**<br/>
https://channel9.msdn.com/events/Build/2016/Panel-Engineering-Quality (With Jonathan Lipps!)<br/>
https://channel9.msdn.com/events/Build/2016/P499 (Includes demos)<br/>

To vote on new features go to https://wpdev.uservoice.com/forums/110705-universal-windows-platform and enter a new feature request under the **UI Testing** category.

## Vote on New Features
Go to https://wpdev.uservoice.com/forums/110705-universal-windows-platform and enter requests under the **UI Testing** category.

## Getting Started
1. Download Windows Application Driver Installer here: http://download.microsoft.com/download/6/8/7/687DEE85-E907-4A95-8035-8BC969B9EA95/WindowsApplicationDriver.msi
2. Run the Installer on the machine where you will run your test in (the application under test should also be installed on this machine)
3. Browse to the Windows Application Driver installation directory and run `WinAppDriver.exe`
4. Open any sample test solution (see the samples in this github project) with Visual Studio 2015 under https://github.com/Microsoft/WinAppDriver/tree/master/Samples.<br/>For example, pull and open `CalculatorTest.sln` under [CalculatorTest](https://github.com/Microsoft/WinAppDriver/tree/master/Samples/CalculatorTest)
5. In Visual Studio 2015 with the test solution open build the test and select **Test > Run > All Tests**


When running `WinAppDriver.exe` a console window is opened which logs the JSON Wire Protocol HTTP requests

> Default listening address is 127.0.0.1:4723. You can configure `WinAppDriver.exe` to listen to a different IP address and port if you run it as administrator.
## C# Samples
1. see Samples/C# in this github project. Open one of the test solutions with Visual Studio 2015. For example, pull and open `CalculatorTest.sln` under [CalculatorTest](https://github.com/Microsoft/WinAppDriver/tree/master/Samples/C%23/CalculatorTest)
2. In Visual Studio 2015 with the test solution open build the test and select **Test > Run > All Tests**

## Java Samples
1. see Samples/Java in this github project. Open the sample folder as an existing project in a Java IDE such as IntelliJ. For example: [CalculatorTest](https://github.com/Microsoft/WinAppDriver/tree/master/Samples/Java/CalculatorTest)
2. In the Java IDE build and run the test

## Features

Windows Application Driver supports testing **Universal Windows Platform (UWP)** and **Classic Windows (Win32)** apps on **Windows 10 PC**.

Windows Application Driver supports testing **Universal Windows Platform (UWP)** and **Classic Windows (Win32)** apps on **Windows 10 PC**

## Currently Supported API's

Expand Down Expand Up @@ -107,7 +110,6 @@ AlarmClockSession.FindElementByAccessibilityId("AlarmNameTextBox").Clear();

> When testing the application you authored yourself, you can find the **Application Id** in the generetated `AppX\vs.appxrecipe` file under `RegisteredUserNmodeAppID` node. E.g. ```c24c8163-548e-4b84-a466-530178fc0580_scyf5npe3hv32!App```

### Classic Windows App Testing

To test a classic Windows app, you can also use any Selenium supported language and specify the **full executable path** for the app under test in the **app** capabilities entry. Below is an example of creating a test session for Windows **Notepad** app:
Expand Down
2 changes: 2 additions & 0 deletions Samples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
project.lock.json
*.user
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,14 @@ public string ReadLocalTime()
localTimeText = worldClockPivotItem.FindElementByClassName("ClockCardItem").Text;
var timeStrings = localTimeText.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

if (timeStrings.Length >= 5)
foreach (string timeString in timeStrings)
{
// Get the time. E.g. "Local time, Monday, February 22, 2016, 11:32 AM, "
localTimeText = timeStrings[4];
// Get the time. E.g. "11:32 AM" from "Local time, Monday, February 22, 2016, 11:32 AM, "
if (timeString.Contains(":"))
{
localTimeText = timeString;
break;
}
}
}

Expand All @@ -121,9 +125,8 @@ public void AddAlarm(string timeText)
if (timeText.Length > 0)
{
// Create a test alarm 1 minute after the read local time
string alarmTimeString = timeText;
DateTimeFormatInfo fi = new CultureInfo("en-US", false).DateTimeFormat;
DateTime alarmTime = DateTime.ParseExact(alarmTimeString, " h:mm tt", fi);
DateTimeFormatInfo fi = CultureInfo.CurrentUICulture.DateTimeFormat;
DateTime alarmTime = DateTime.Parse(timeText, fi);
alarmTime = alarmTime.AddMinutes(1.0);
string hourString = alarmTime.ToString("%h", fi);
string minuteString = alarmTime.ToString("mm", fi);
Expand Down
File renamed without changes.
62 changes: 62 additions & 0 deletions Samples/C#/BaseConverterTest/BaseConverterTest.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BaseConverterUWP", "BaseConverterUWP\BaseConverterUWP.csproj", "{8465E874-BFC7-4B8A-B9BB-E710DB67F520}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BaseConverterUITest", "BaseConverterUITest\BaseConverterUITest.csproj", "{8D72292F-6450-4AEE-91B5-4C34A225C9CE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8465E874-BFC7-4B8A-B9BB-E710DB67F520}.Debug|Any CPU.ActiveCfg = Debug|x86
{8465E874-BFC7-4B8A-B9BB-E710DB67F520}.Debug|ARM.ActiveCfg = Debug|ARM
{8465E874-BFC7-4B8A-B9BB-E710DB67F520}.Debug|ARM.Build.0 = Debug|ARM
{8465E874-BFC7-4B8A-B9BB-E710DB67F520}.Debug|ARM.Deploy.0 = Debug|ARM
{8465E874-BFC7-4B8A-B9BB-E710DB67F520}.Debug|x64.ActiveCfg = Debug|x64
{8465E874-BFC7-4B8A-B9BB-E710DB67F520}.Debug|x64.Build.0 = Debug|x64
{8465E874-BFC7-4B8A-B9BB-E710DB67F520}.Debug|x64.Deploy.0 = Debug|x64
{8465E874-BFC7-4B8A-B9BB-E710DB67F520}.Debug|x86.ActiveCfg = Debug|x86
{8465E874-BFC7-4B8A-B9BB-E710DB67F520}.Debug|x86.Build.0 = Debug|x86
{8465E874-BFC7-4B8A-B9BB-E710DB67F520}.Debug|x86.Deploy.0 = Debug|x86
{8465E874-BFC7-4B8A-B9BB-E710DB67F520}.Release|Any CPU.ActiveCfg = Release|x86
{8465E874-BFC7-4B8A-B9BB-E710DB67F520}.Release|ARM.ActiveCfg = Release|ARM
{8465E874-BFC7-4B8A-B9BB-E710DB67F520}.Release|ARM.Build.0 = Release|ARM
{8465E874-BFC7-4B8A-B9BB-E710DB67F520}.Release|ARM.Deploy.0 = Release|ARM
{8465E874-BFC7-4B8A-B9BB-E710DB67F520}.Release|x64.ActiveCfg = Release|x64
{8465E874-BFC7-4B8A-B9BB-E710DB67F520}.Release|x64.Build.0 = Release|x64
{8465E874-BFC7-4B8A-B9BB-E710DB67F520}.Release|x64.Deploy.0 = Release|x64
{8465E874-BFC7-4B8A-B9BB-E710DB67F520}.Release|x86.ActiveCfg = Release|x86
{8465E874-BFC7-4B8A-B9BB-E710DB67F520}.Release|x86.Build.0 = Release|x86
{8465E874-BFC7-4B8A-B9BB-E710DB67F520}.Release|x86.Deploy.0 = Release|x86
{8D72292F-6450-4AEE-91B5-4C34A225C9CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8D72292F-6450-4AEE-91B5-4C34A225C9CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D72292F-6450-4AEE-91B5-4C34A225C9CE}.Debug|ARM.ActiveCfg = Debug|Any CPU
{8D72292F-6450-4AEE-91B5-4C34A225C9CE}.Debug|ARM.Build.0 = Debug|Any CPU
{8D72292F-6450-4AEE-91B5-4C34A225C9CE}.Debug|x64.ActiveCfg = Debug|Any CPU
{8D72292F-6450-4AEE-91B5-4C34A225C9CE}.Debug|x64.Build.0 = Debug|Any CPU
{8D72292F-6450-4AEE-91B5-4C34A225C9CE}.Debug|x86.ActiveCfg = Debug|Any CPU
{8D72292F-6450-4AEE-91B5-4C34A225C9CE}.Debug|x86.Build.0 = Debug|Any CPU
{8D72292F-6450-4AEE-91B5-4C34A225C9CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8D72292F-6450-4AEE-91B5-4C34A225C9CE}.Release|Any CPU.Build.0 = Release|Any CPU
{8D72292F-6450-4AEE-91B5-4C34A225C9CE}.Release|ARM.ActiveCfg = Release|Any CPU
{8D72292F-6450-4AEE-91B5-4C34A225C9CE}.Release|ARM.Build.0 = Release|Any CPU
{8D72292F-6450-4AEE-91B5-4C34A225C9CE}.Release|x64.ActiveCfg = Release|Any CPU
{8D72292F-6450-4AEE-91B5-4C34A225C9CE}.Release|x64.Build.0 = Release|Any CPU
{8D72292F-6450-4AEE-91B5-4C34A225C9CE}.Release|x86.ActiveCfg = Release|Any CPU
{8D72292F-6450-4AEE-91B5-4C34A225C9CE}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8D72292F-6450-4AEE-91B5-4C34A225C9CE}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BaseConverterUITest</RootNamespace>
<AssemblyName>BaseConverterUITest</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="WebDriver, Version=2.53.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Selenium.WebDriver.2.53.0\lib\net40\WebDriver.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="UnitTest1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("BaseConverterUITest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BaseConverterUITest")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("8d72292f-6450-4aee-91b5-4c34a225c9ce")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
71 changes: 71 additions & 0 deletions Samples/C#/BaseConverterTest/BaseConverterUITest/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//******************************************************************************
//
// Copyright (c) 2016 Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT).
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
//******************************************************************************

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Remote;

namespace BaseConverterUITest
{
[TestClass]
public class UnitTest1
{
protected const string AppDriverUrl = "http://127.0.0.1:4723";
protected static RemoteWebDriver TestAppSession;
protected static RemoteWebElement TestAppResult;

[ClassInitialize]
public static void Setup(TestContext context)
{
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", "67017b09-d193-4676-a8a5-9d474e2f2c74_1gb0zh1xa1sqe!App");
TestAppSession = new RemoteWebDriver(new Uri(AppDriverUrl), appCapabilities);

Assert.IsNotNull(TestAppSession);
}
[TestMethod]
public void ConvertBaseTest()
{
var boxes = TestAppSession.FindElementsByClassName("TextBox");
for (int i = 0; i < boxes.Count; i++)
{
var item = boxes[i];
if (i == 0)
{
item.SendKeys("16");
}
else if (i == 1)
{
item.SendKeys("2");
}
else
{
//do nothing
}
}

var button = TestAppSession.FindElementByClassName("Button");
button.Click();

/*Verify the conversion happened successfully by locating the converted item on the page
*In this case, converting 16 from base 10 to base 2 should yield 10,000 as the result*/
TestAppResult = TestAppSession.FindElementByName("10000") as RemoteWebElement;
Assert.IsNotNull(TestAppResult);

TestAppSession.Dispose();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Selenium.WebDriver" version="2.53.0" targetFramework="net452" />
</packages>
8 changes: 8 additions & 0 deletions Samples/C#/BaseConverterTest/BaseConverterUWP/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Application
x:Class="BaseConverterUWP.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:BaseConverterUWP"
RequestedTheme="Light">

</Application>
Loading

0 comments on commit 65b460d

Please sign in to comment.