Skip to content

Commit dd641e5

Browse files
committed
Merged PR 2174094: Create samples and unit tests for W3C Actions API endpoint covering pen and multi touch interactions
Create a new Paint3DTest sample test project highlighting multi-touch and pen input feature Create a new Paint sample test project highlighting multi-touch feature and performance Create a sample test to demonstrate pen actions using built-in Sticky Notes application Create new unit tests for the new W3C WebDriver Actions API endpoint Update WebDriverAPI to use appium-dotnet-driver preview that has W3C WebDriver Actions API Related work items: #16393884, #16393929, #17988917
2 parents 9373cbd + c530424 commit dd641e5

34 files changed

+3036
-36
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
//******************************************************************************
2+
//
3+
// Copyright (c) 2018 Microsoft Corporation. All rights reserved.
4+
//
5+
// This code is licensed under the MIT License (MIT).
6+
//
7+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
8+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
10+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
11+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
12+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
13+
// THE SOFTWARE.
14+
//
15+
//******************************************************************************
16+
17+
using Microsoft.VisualStudio.TestTools.UnitTesting;
18+
using OpenQA.Selenium;
19+
using OpenQA.Selenium.Appium.Windows;
20+
using OpenQA.Selenium.Remote;
21+
using System;
22+
23+
namespace Paint3DTest
24+
{
25+
public class Paint3DSession
26+
{
27+
// Note: append /wd/hub to the URL if you're directing the test at Appium
28+
protected const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723";
29+
private const string Paint3DAppId = @"Microsoft.MSPaint_8wekyb3d8bbwe!Microsoft.MSPaint";
30+
31+
protected static WindowsDriver<WindowsElement> session;
32+
33+
public static void Setup(TestContext context)
34+
{
35+
// Launch Paint 3D application if it is not yet launched
36+
if (session == null)
37+
{
38+
// Create a new session to launch Paint 3D application
39+
DesiredCapabilities appCapabilities = new DesiredCapabilities();
40+
appCapabilities.SetCapability("app", Paint3DAppId);
41+
appCapabilities.SetCapability("deviceName", "WindowsPC");
42+
session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);
43+
Assert.IsNotNull(session);
44+
45+
// Set implicit timeout to 1.5 seconds to make element search to retry every 500 ms for at most three times
46+
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5);
47+
48+
// Maximize Paint 3D window to ensure all controls being displayed
49+
session.Manage().Window.Maximize();
50+
}
51+
}
52+
53+
public static void TearDown()
54+
{
55+
// Close the application and delete the session
56+
if (session != null)
57+
{
58+
ClosePaint3D();
59+
session.Quit();
60+
session = null;
61+
}
62+
}
63+
64+
[TestInitialize]
65+
public void CreateNewPaint3DProject()
66+
{
67+
try
68+
{
69+
session.FindElementByAccessibilityId("WelcomeScreenNewButton").Click();
70+
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1));
71+
}
72+
catch
73+
{
74+
// Create a new Paint 3D project by pressing Ctrl + N
75+
session.SwitchTo().Window(session.CurrentWindowHandle);
76+
session.Keyboard.SendKeys(Keys.Control + "n" + Keys.Control);
77+
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1));
78+
DismissSaveConfirmDialog();
79+
}
80+
}
81+
82+
private static void DismissSaveConfirmDialog()
83+
{
84+
try
85+
{
86+
WindowsElement closeSaveConfirmDialog = session.FindElementByAccessibilityId("CloseSaveConfirmDialog");
87+
closeSaveConfirmDialog.FindElementByAccessibilityId("SecondaryBtnG3").Click();
88+
}
89+
catch { }
90+
}
91+
92+
private static void ClosePaint3D()
93+
{
94+
try
95+
{
96+
session.Close();
97+
string currentHandle = session.CurrentWindowHandle; // This should throw if the window is closed successfully
98+
99+
// When the Paint 3D window remains open because of save confirmation dialog, attempt to close modal dialog
100+
DismissSaveConfirmDialog();
101+
}
102+
catch { }
103+
}
104+
}
105+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="packages\MSTest.TestAdapter.1.2.1\build\net45\MSTest.TestAdapter.props" Condition="Exists('packages\MSTest.TestAdapter.1.2.1\build\net45\MSTest.TestAdapter.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{98E13E3A-A110-4694-BFA7-3F4E8CC173A4}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>Paint3DTest</RootNamespace>
11+
<AssemblyName>Paint3DTest</AssemblyName>
12+
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
15+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
16+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
17+
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
18+
<IsCodedUITest>False</IsCodedUITest>
19+
<TestProjectType>UnitTest</TestProjectType>
20+
<NuGetPackageImportStamp>
21+
</NuGetPackageImportStamp>
22+
</PropertyGroup>
23+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
24+
<DebugSymbols>true</DebugSymbols>
25+
<DebugType>full</DebugType>
26+
<Optimize>false</Optimize>
27+
<OutputPath>bin\Debug\</OutputPath>
28+
<DefineConstants>DEBUG;TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
33+
<DebugType>pdbonly</DebugType>
34+
<Optimize>true</Optimize>
35+
<OutputPath>bin\Release\</OutputPath>
36+
<DefineConstants>TRACE</DefineConstants>
37+
<ErrorReport>prompt</ErrorReport>
38+
<WarningLevel>4</WarningLevel>
39+
</PropertyGroup>
40+
<ItemGroup>
41+
<Reference Include="appium-dotnet-driver, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
42+
<HintPath>packages\Microsoft.WinAppDriver.Appium.WebDriver.1.0.1-Preview\lib\net45\appium-dotnet-driver.dll</HintPath>
43+
</Reference>
44+
<Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
45+
<HintPath>packages\Castle.Core.4.2.1\lib\net45\Castle.Core.dll</HintPath>
46+
</Reference>
47+
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
48+
<HintPath>packages\MSTest.TestFramework.1.2.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
49+
</Reference>
50+
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
51+
<HintPath>packages\MSTest.TestFramework.1.2.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
52+
</Reference>
53+
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
54+
<HintPath>packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
55+
</Reference>
56+
<Reference Include="System" />
57+
<Reference Include="System.Configuration" />
58+
<Reference Include="System.Core" />
59+
<Reference Include="System.Drawing" />
60+
<Reference Include="WebDriver, Version=3.8.0.0, Culture=neutral, processorArchitecture=MSIL">
61+
<HintPath>packages\Selenium.WebDriver.3.8.0\lib\net45\WebDriver.dll</HintPath>
62+
</Reference>
63+
<Reference Include="WebDriver.Support, Version=3.8.0.0, Culture=neutral, processorArchitecture=MSIL">
64+
<HintPath>packages\Selenium.Support.3.8.0\lib\net45\WebDriver.Support.dll</HintPath>
65+
</Reference>
66+
</ItemGroup>
67+
<ItemGroup>
68+
<Compile Include="Paint3DSession.cs" />
69+
<Compile Include="Properties\AssemblyInfo.cs" />
70+
<Compile Include="ScenarioDraw.cs" />
71+
<Compile Include="ScenarioZoom.cs" />
72+
</ItemGroup>
73+
<ItemGroup>
74+
<None Include="packages.config" />
75+
</ItemGroup>
76+
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
77+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
78+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
79+
<PropertyGroup>
80+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
81+
</PropertyGroup>
82+
<Error Condition="!Exists('packages\MSTest.TestAdapter.1.2.1\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\MSTest.TestAdapter.1.2.1\build\net45\MSTest.TestAdapter.props'))" />
83+
<Error Condition="!Exists('packages\MSTest.TestAdapter.1.2.1\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\MSTest.TestAdapter.1.2.1\build\net45\MSTest.TestAdapter.targets'))" />
84+
</Target>
85+
<Import Project="packages\MSTest.TestAdapter.1.2.1\build\net45\MSTest.TestAdapter.targets" Condition="Exists('packages\MSTest.TestAdapter.1.2.1\build\net45\MSTest.TestAdapter.targets')" />
86+
</Project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.27703.2035
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Paint3DTest", "Paint3DTest.csproj", "{98E13E3A-A110-4694-BFA7-3F4E8CC173A4}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{98E13E3A-A110-4694-BFA7-3F4E8CC173A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{98E13E3A-A110-4694-BFA7-3F4E8CC173A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{98E13E3A-A110-4694-BFA7-3F4E8CC173A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{98E13E3A-A110-4694-BFA7-3F4E8CC173A4}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {224533C9-3B8E-48D8-B7CD-940357E4EED6}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
[assembly: AssemblyTitle("Paint3DTest")]
6+
[assembly: AssemblyDescription("")]
7+
[assembly: AssemblyConfiguration("")]
8+
[assembly: AssemblyCompany("")]
9+
[assembly: AssemblyProduct("Paint3DTest")]
10+
[assembly: AssemblyCopyright("Copyright © 2018")]
11+
[assembly: AssemblyTrademark("")]
12+
[assembly: AssemblyCulture("")]
13+
14+
[assembly: ComVisible(false)]
15+
16+
[assembly: Guid("98e13e3a-a110-4694-bfa7-3f4e8cc173a4")]
17+
18+
// [assembly: AssemblyVersion("1.0.*")]
19+
[assembly: AssemblyVersion("1.0.0.0")]
20+
[assembly: AssemblyFileVersion("1.0.0.0")]

Samples/C#/Paint3DTest/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Paint3DTest
2+
3+
Paint3DTest is a sample test project that demonstrates how to perform pen and multi-touch interactions through the actions API using the Windows 10 built-in **Paint 3D** application.
4+
5+
This test project highlights some Actions API interactions below.
6+
- Drawing and erasing using pen strokes
7+
- Performing pinch and zoom multi-touch gestures
8+
9+
10+
## Requirements
11+
12+
- Windows 10 PC with the latest Windows 10 version (Version 1607 or later)
13+
- Microsoft Visual Studio 2017 or later
14+
15+
16+
## Getting Started
17+
18+
1. [Run](../../../README.md#installing-and-running-windows-application-driver) `WinAppDriver.exe` on the test device
19+
1. Open `Paint3DTest.sln` in Visual Studio
20+
2. Select **Test** > **Windows** > **Test Explorer**
21+
3. Select **Run All** on the test pane or through menu **Test** > **Run** > **All Tests**
22+
23+
> Once the project is successfully built, you can use the **TestExplorer** to pick and choose the test scenario(s) to run
24+
25+
26+
## Including proper appium-dotnet-driver NuGet package
27+
28+
Pen and multi-touch input support in Windows Application Driver is accessed using W3C WebDriver Actions API. Currently this feature is only supported
29+
through a temporary `WinAppDriver.Preview.Appium.WebDriver` instead of the official `Appium.WebDriver` NuGet package. This sample test
30+
is using this temporary NuGet package as shown in [packages.config](./packages.config).
31+
32+
To make use all the pen features through the library in the NuGet package above, use the `OpenQA.Selenium.Appium.Interactions.PointerInputDevice`
33+
instead of the `OpenQA.Selenium.Interactions.PointerInputDevice`.
34+
35+
36+
## Adding/Updating Test Scenario
37+
38+
Please follow the guidelines below to maintain test reliability and conciseness:
39+
1. Group test methods based on the relevant scenarios such as **Draw** and **Zoom**
40+
2. Maintain original state after test runs and keep clean state in between tests when possible
41+
3. Only add tests that provide additional value to the sample

0 commit comments

Comments
 (0)