Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 4e5af4d

Browse files
author
alakshmi1030
committed
Added windows sample apps to windows_samples branch
1 parent 8a10d9a commit 4e5af4d

10 files changed

Lines changed: 650 additions & 0 deletions

File tree

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
//******************************************************************************
2+
//
3+
// Copyright (c) 2016 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 System;
18+
using Microsoft.VisualStudio.TestTools.UnitTesting;
19+
using OpenQA.Selenium.Remote;
20+
21+
namespace CalculatorTest
22+
{
23+
[TestClass]
24+
public class BasicScenarios
25+
{
26+
protected const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723/wd/hub";
27+
protected static RemoteWebDriver CalculatorSession;
28+
protected static RemoteWebElement CalculatorResult;
29+
protected static string OriginalCalculatorMode;
30+
31+
[ClassInitialize]
32+
public static void Setup(TestContext context)
33+
{
34+
// Launch the calculator app
35+
DesiredCapabilities appCapabilities = new DesiredCapabilities();
36+
appCapabilities.SetCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");
37+
appCapabilities.SetCapability("platformName", "Windows");
38+
appCapabilities.SetCapability("deviceName", "WindowsPC");
39+
CalculatorSession = new RemoteWebDriver(new Uri(WindowsApplicationDriverUrl), appCapabilities);
40+
Assert.IsNotNull(CalculatorSession);
41+
CalculatorSession.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(2));
42+
43+
// Make sure we're in standard mode
44+
CalculatorSession.FindElementByXPath("//Button[starts-with(@Name, \"Menu\")]").Click();
45+
OriginalCalculatorMode = CalculatorSession.FindElementByXPath("//List[@AutomationId=\"FlyoutNav\"]//ListItem[@IsSelected=\"True\"]").Text;
46+
CalculatorSession.FindElementByXPath("//ListItem[@Name=\"Standard Calculator\"]").Click();
47+
48+
// Use series of operation to locate the calculator result text element as a workaround
49+
// We currently cannot query element by automationId without using modified appium dot net driver
50+
// TODO: Use a proper appium/webdriver nuget package that allow us to query based on automationId
51+
CalculatorSession.FindElementByXPath("//Button[@Name=\"Clear\"]").Click();
52+
CalculatorSession.FindElementByXPath("//Button[@Name=\"Seven\"]").Click();
53+
CalculatorResult = CalculatorSession.FindElementByName("Display is 7 ") as RemoteWebElement;
54+
Assert.IsNotNull(CalculatorResult);
55+
}
56+
57+
[ClassCleanup]
58+
public static void TearDown()
59+
{
60+
// Restore original mode before closing down
61+
CalculatorSession.FindElementByXPath("//Button[starts-with(@Name, \"Menu\")]").Click();
62+
CalculatorSession.FindElementByXPath("//ListItem[@Name=\"" + OriginalCalculatorMode + "\"]").Click();
63+
64+
CalculatorResult = null;
65+
CalculatorSession.Dispose();
66+
CalculatorSession = null;
67+
}
68+
69+
[TestInitialize]
70+
public void Clear()
71+
{
72+
CalculatorSession.FindElementByName("Clear").Click();
73+
Assert.AreEqual("Display is 0 ", CalculatorResult.Text);
74+
}
75+
76+
[TestMethod]
77+
public void Addition()
78+
{
79+
CalculatorSession.FindElementByName("One").Click();
80+
CalculatorSession.FindElementByName("Plus").Click();
81+
CalculatorSession.FindElementByName("Seven").Click();
82+
CalculatorSession.FindElementByName("Equals").Click();
83+
Assert.AreEqual("Display is 8 ", CalculatorResult.Text);
84+
}
85+
86+
[TestMethod]
87+
public void Combination()
88+
{
89+
CalculatorSession.FindElementByXPath("//Button[@Name=\"Seven\"]").Click();
90+
CalculatorSession.FindElementByXPath("//Button[@Name=\"Multiply by\"]").Click();
91+
CalculatorSession.FindElementByXPath("//Button[@Name=\"Nine\"]").Click();
92+
CalculatorSession.FindElementByXPath("//Button[@Name=\"Plus\"]").Click();
93+
CalculatorSession.FindElementByXPath("//Button[@Name=\"One\"]").Click();
94+
CalculatorSession.FindElementByXPath("//Button[@Name=\"Equals\"]").Click();
95+
CalculatorSession.FindElementByXPath("//Button[@Name=\"Divide by\"]").Click();
96+
CalculatorSession.FindElementByXPath("//Button[@Name=\"Eight\"]").Click();
97+
CalculatorSession.FindElementByXPath("//Button[@Name=\"Equals\"]").Click();
98+
Assert.AreEqual("Display is 8 ", CalculatorResult.Text);
99+
}
100+
101+
[TestMethod]
102+
public void Division()
103+
{
104+
CalculatorSession.FindElementByName("Eight").Click();
105+
CalculatorSession.FindElementByName("Eight").Click();
106+
CalculatorSession.FindElementByName("Divide by").Click();
107+
CalculatorSession.FindElementByName("One").Click();
108+
CalculatorSession.FindElementByName("One").Click();
109+
CalculatorSession.FindElementByName("Equals").Click();
110+
Assert.AreEqual("Display is 8 ", CalculatorResult.Text);
111+
}
112+
113+
[TestMethod]
114+
public void Multiplication()
115+
{
116+
CalculatorSession.FindElementByName("Nine").Click();
117+
CalculatorSession.FindElementByName("Multiply by").Click();
118+
CalculatorSession.FindElementByName("Nine").Click();
119+
CalculatorSession.FindElementByName("Equals").Click();
120+
Assert.AreEqual("Display is 81 ", CalculatorResult.Text);
121+
}
122+
123+
[TestMethod]
124+
public void Subtraction()
125+
{
126+
CalculatorSession.FindElementByName("Nine").Click();
127+
CalculatorSession.FindElementByName("Minus").Click();
128+
CalculatorSession.FindElementByName("One").Click();
129+
CalculatorSession.FindElementByName("Equals").Click();
130+
Assert.AreEqual("Display is 8 ", CalculatorResult.Text);
131+
}
132+
}
133+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<AppDesignerFolder>Properties</AppDesignerFolder>
9+
<RootNamespace>CalculatorTest</RootNamespace>
10+
<AssemblyName>CalculatorTest</AssemblyName>
11+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
15+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
16+
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
17+
<IsCodedUITest>False</IsCodedUITest>
18+
<TestProjectType>UnitTest</TestProjectType>
19+
</PropertyGroup>
20+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
21+
<DebugSymbols>true</DebugSymbols>
22+
<DebugType>full</DebugType>
23+
<Optimize>false</Optimize>
24+
<OutputPath>bin\Debug\</OutputPath>
25+
<DefineConstants>DEBUG;TRACE</DefineConstants>
26+
<ErrorReport>prompt</ErrorReport>
27+
<WarningLevel>4</WarningLevel>
28+
</PropertyGroup>
29+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
30+
<DebugType>pdbonly</DebugType>
31+
<Optimize>true</Optimize>
32+
<OutputPath>bin\Release\</OutputPath>
33+
<DefineConstants>TRACE</DefineConstants>
34+
<ErrorReport>prompt</ErrorReport>
35+
<WarningLevel>4</WarningLevel>
36+
</PropertyGroup>
37+
<ItemGroup>
38+
<Reference Include="System" />
39+
<Reference Include="System.Drawing" />
40+
<Reference Include="WebDriver, Version=2.52.0.0, Culture=neutral, processorArchitecture=MSIL">
41+
<HintPath>packages\Selenium.WebDriver.2.52.0\lib\net40\WebDriver.dll</HintPath>
42+
<Private>True</Private>
43+
</Reference>
44+
</ItemGroup>
45+
<Choose>
46+
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
47+
<ItemGroup>
48+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
49+
</ItemGroup>
50+
</When>
51+
<Otherwise>
52+
<ItemGroup>
53+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
54+
</ItemGroup>
55+
</Otherwise>
56+
</Choose>
57+
<ItemGroup>
58+
<Compile Include="BasicScenarios.cs" />
59+
<Compile Include="Properties\AssemblyInfo.cs" />
60+
</ItemGroup>
61+
<ItemGroup>
62+
<None Include="app.config" />
63+
<None Include="packages.config" />
64+
</ItemGroup>
65+
<Choose>
66+
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
67+
<ItemGroup>
68+
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
69+
<Private>False</Private>
70+
</Reference>
71+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
72+
<Private>False</Private>
73+
</Reference>
74+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
75+
<Private>False</Private>
76+
</Reference>
77+
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
78+
<Private>False</Private>
79+
</Reference>
80+
</ItemGroup>
81+
</When>
82+
</Choose>
83+
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
84+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
85+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
86+
Other similar extension points exist, see Microsoft.Common.targets.
87+
<Target Name="BeforeBuild">
88+
</Target>
89+
<Target Name="AfterBuild">
90+
</Target>
91+
-->
92+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.23107.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CalculatorTest", "CalculatorTest.csproj", "{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}"
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+
{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//******************************************************************************
2+
//
3+
// Copyright (c) 2016 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 System.Reflection;
18+
using System.Runtime.CompilerServices;
19+
using System.Runtime.InteropServices;
20+
21+
// General Information about an assembly is controlled through the following
22+
// set of attributes. Change these attribute values to modify the information
23+
// associated with an assembly.
24+
[assembly: AssemblyTitle("CalculatorTest")]
25+
[assembly: AssemblyDescription("")]
26+
[assembly: AssemblyConfiguration("")]
27+
[assembly: AssemblyCompany("")]
28+
[assembly: AssemblyProduct("CalculatorTest")]
29+
[assembly: AssemblyCopyright("Copyright © 2016 Microsoft Corporation")]
30+
[assembly: AssemblyTrademark("")]
31+
[assembly: AssemblyCulture("")]
32+
33+
// Setting ComVisible to false makes the types in this assembly not visible
34+
// to COM components. If you need to access a type in this assembly from
35+
// COM, set the ComVisible attribute to true on that type.
36+
[assembly: ComVisible(false)]
37+
38+
// The following GUID is for the ID of the typelib if this project is exposed to COM
39+
[assembly: Guid("b2c5adff-d6b5-48c1-bb8c-571bfd583d7f")]
40+
41+
// Version information for an assembly consists of the following four values:
42+
//
43+
// Major Version
44+
// Minor Version
45+
// Build Number
46+
// Revision
47+
//
48+
// You can specify all the values or you can default the Build and Revision Numbers
49+
// by using the '*' as shown below:
50+
// [assembly: AssemblyVersion("1.0.*")]
51+
[assembly: AssemblyVersion("1.0.0.0")]
52+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<runtime>
4+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
5+
<dependentAssembly>
6+
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
7+
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
8+
</dependentAssembly>
9+
</assemblyBinding>
10+
</runtime>
11+
</configuration>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Selenium.WebDriver" version="2.52.0" targetFramework="net45" />
4+
</packages>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>CalculatorTest</groupId>
8+
<artifactId>CalculatorTest</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<dependencies>
12+
<dependency>
13+
<groupId>org.seleniumhq.selenium</groupId>
14+
<artifactId>selenium-java</artifactId>
15+
<version>2.53.0</version>
16+
</dependency>
17+
<dependency>
18+
<groupId>junit</groupId>
19+
<artifactId>junit</artifactId>
20+
<version>4.11</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>io.appium</groupId>
24+
<artifactId>java-client</artifactId>
25+
<version>3.4.1</version>
26+
</dependency>
27+
</dependencies>
28+
29+
</project>

0 commit comments

Comments
 (0)