Skip to content

Commit

Permalink
Merge remote-tracking branch 'GitHub'
Browse files Browse the repository at this point in the history
  • Loading branch information
timotiusmargo committed Nov 30, 2016
2 parents 69bed54 + 36276ed commit c7f8dbd
Show file tree
Hide file tree
Showing 19 changed files with 862 additions and 38 deletions.
63 changes: 63 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ This Github project provides
- issue tracking

**Videos about WinAppDriver**<br/>
https://channel9.msdn.com/events/Connect/2016/202 (8min overview with demos)<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/>
https://channel9.msdn.com/events/Build/2016/P499 (Longer discussion)<br/>
https://www.youtube.com/watch?v=XAJVpvaEchY (c# demo with calculator sample walkthrough)<br/>

## Vote on New Features
Go to https://wpdev.uservoice.com/forums/110705-universal-windows-platform and enter requests under the **UI Testing** category.
Expand Down Expand Up @@ -45,7 +47,7 @@ WinAppDriver.exe *IP address* *port* For example:
5. If the test app is installed on the remote machine run your test script and see the results!

## 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)
1. see Samples/C# in this github project. Take a look at https://www.youtube.com/watch?v=XAJVpvaEchY for a walkthrough of the c# calculator sample. 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
Expand Down Expand Up @@ -108,7 +110,8 @@ Windows Application Driver supports testing **Universal Windows Platform (UWP)**
You can choose any programming language or tools supported by Appium/Selenium to write your test scripts. In the example below, we will author the test script in C# using Microsoft Visual Studio 2015.

### Create Test Project
1. Open **Microsoft Visual Studio 2015**
1. Open **Microsoft Visual Studio 2015 or 2017** <br/>
NOTE: in Visual Studio 2017 make sure you have the optional “.NET desktop development” workload installed
2. Create the test project and solution. I.e. select **New Project > Templates > Visual C# > Test > Unit Test Project**
3. Once created, select **Project > Manage NuGet Packages... > Browse** and search for **Appium.WebDriver**
4. Install the **Appium.WebDriver** NuGet packages for the test project
Expand Down Expand Up @@ -141,7 +144,7 @@ DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", @"C:\Windows\System32\notepad.exe");
NotepadSession = new IOSDriver<IOSElement>(new Uri("http://127.0.0.1:4723"), appCapabilities);

// Control the AlarmClock app
// Control the Notepad app
NotepadSession.FindElementByClassName("Edit").SendKeys("This is some text");
```

Expand Down
173 changes: 173 additions & 0 deletions Samples/C#/CalculatorTest/AdvancedScenarios.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
//******************************************************************************
//
// 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 CalculatorTest
{
[TestClass]
public class AdvancedScenarios
{
protected const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723";
protected static RemoteWebDriver CalculatorSession;
protected static RemoteWebElement CalculatorResult;
protected static string OriginalCalculatorMode;

[ClassInitialize]
public static void Setup(TestContext context)
{
// Launch the calculator app
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");
CalculatorSession = new RemoteWebDriver(new Uri(WindowsApplicationDriverUrl), appCapabilities);
Assert.IsNotNull(CalculatorSession);
CalculatorSession.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(4));

// Make sure we're in standard mode
CalculatorSession.FindElementByXPath("//Button[starts-with(@Name, \"Menu\")]").Click();
OriginalCalculatorMode = CalculatorSession.FindElementByXPath("//List[@AutomationId=\"FlyoutNav\"]//ListItem[@IsSelected=\"True\"]").Text;
CalculatorSession.FindElementByXPath("//ListItem[@Name=\"Standard Calculator\"]").Click();

// Use series of operation to locate the calculator result text element as a workaround
// We currently cannot query element by automationId without using modified appium dot net driver
// TODO: Use a proper appium/webdriver nuget package that allow us to query based on automationId
CalculatorSession.FindElementByXPath("//Button[@Name=\"Clear\"]").Click();
CalculatorSession.FindElementByXPath("//Button[@Name=\"Seven\"]").Click();
CalculatorResult = CalculatorSession.FindElementByName("Display is 7 ") as RemoteWebElement;
Assert.IsNotNull(CalculatorResult);
}

[ClassCleanup]
public static void TearDown()
{
// Restore original mode before closing down
CalculatorSession.FindElementByXPath("//Button[starts-with(@Name, \"Menu\")]").Click();
CalculatorSession.FindElementByXPath("//ListItem[@Name=\"" + OriginalCalculatorMode + "\"]").Click();

CalculatorResult = null;
CalculatorSession.Dispose();
CalculatorSession = null;
}

[TestInitialize]
public void Clear()
{
CalculatorSession.FindElementByName("Clear").Click();
Assert.AreEqual("Display is 0 ", CalculatorResult.Text);
}

[TestMethod]
[DataRow("One", "Plus", "One", "Equals", "2 ")]
[DataRow("One", "Plus", "Two", "Equals", "3 ")]
[DataRow("One", "Plus", "Three", "Equals", "4 ")]
[DataRow("One", "Plus", "Four", "Equals", "5 ")]
[DataRow("One", "Plus", "Five", "Equals", "6 ")]
[DataRow("One", "Plus", "Six", "Equals", "7 ")]
[DataRow("One", "Plus", "Seven", "Equals", "8 ")]
[DataRow("One", "Plus", "Eight", "Equals", "9 ")]
[DataRow("One", "Plus", "Nine", "Equals", "10 ")]

[DataRow("Nine", "Plus", "Two", "Equals", "11 ")]
[DataRow("Eight", "Plus", "Four", "Equals", "12 ")]
[DataRow("Seven", "Plus", "Six", "Equals", "13 ")]
[DataRow("Six", "Plus", "Eight", "Equals", "14 ")]
[DataRow("Six", "Plus", "Nine", "Equals", "15 ")]
[DataRow("Seven", "Plus", "Nine", "Equals", "16 ")]
[DataRow("Nine", "Plus", "Eight", "Equals", "17 ")]
[DataRow("Nine", "Plus", "Nine", "Equals", "18 ")]


public void Addition_Advanced(string input1,string operation,string input2, string equals, string assertion)
{
CalculatorSession.FindElementByName(input1).Click();
CalculatorSession.FindElementByName(operation).Click();
CalculatorSession.FindElementByName(input2).Click();
CalculatorSession.FindElementByName(equals).Click();
Assert.AreEqual("Display is " + assertion, CalculatorResult.Text);
}

[TestMethod]
[DataRow("Seven", "Multiply by", "Nine", "Plus", "One", "Equals", "64 ", "Divide by", "Eight", "Equals", "8 ")]
[DataRow("Nine", "Multiply by", "One", "Plus", "One", "Equals", "10 ", "Divide by", "Five", "Equals", "2 ")]
[DataRow("Eight", "Multiply by", "Two", "Plus", "Two", "Equals", "18 ", "Divide by", "Four", "Equals", "4.5 ")]
[DataRow("Seven", "Multiply by", "Three", "Plus", "Four", "Equals", "25 ", "Divide by", "Four", "Equals", "6.25 ")]
[DataRow("Six", "Multiply by", "Four", "Plus", "One", "Equals", "25 ", "Divide by", "Two", "Equals", "12.5 ")]

public void Combination_Advanced(string input1,string operation1,string input2,string operation2,string input3,string equals1,string assertion1,
string operation3,string input4,string equals2,string assertion2)
{
CalculatorSession.FindElementByXPath("//Button[@Name=\""+input1+"\"]").Click();
CalculatorSession.FindElementByXPath("//Button[@Name=\""+operation1+"\"]").Click();
CalculatorSession.FindElementByXPath("//Button[@Name=\""+ input2+ "\"]").Click();
CalculatorSession.FindElementByXPath("//Button[@Name=\"" + operation2 + "\"]").Click();
CalculatorSession.FindElementByXPath("//Button[@Name=\"" + input3 + "\"]").Click();
CalculatorSession.FindElementByXPath("//Button[@Name=\"" + equals1 + "\"]").Click();
Assert.AreEqual("Display is "+assertion1, CalculatorResult.Text);
CalculatorSession.FindElementByXPath("//Button[@Name=\"" + operation3 + "\"]").Click();
CalculatorSession.FindElementByXPath("//Button[@Name=\"" + input4 + "\"]").Click();
CalculatorSession.FindElementByXPath("//Button[@Name=\"" + equals2 + "\"]").Click();
Assert.AreEqual("Display is " + assertion2, CalculatorResult.Text);
}

[TestMethod]
[DataRow("Eight", "Eight", "Divide by", "One", "One", "Equals", "8 ")]
[DataRow("Six", "Four", "Divide by", "One", "Zero", "Equals", "6.4 ")]
[DataRow("Five", "Five", "Divide by", "One", "Zero", "Equals", "5.5 ")]
public void Division_Advanced(string input1, string input2, string operation, string input3, string input4, string equals, string assertion)
{
CalculatorSession.FindElementByName(input1).Click();
CalculatorSession.FindElementByName(input2).Click();
CalculatorSession.FindElementByName(operation).Click();
CalculatorSession.FindElementByName(input3).Click();
CalculatorSession.FindElementByName(input4).Click();
CalculatorSession.FindElementByName(equals).Click();
Assert.AreEqual("Display is "+assertion, CalculatorResult.Text);
}

[TestMethod]
[DataRow("Nine", "Multiply by", "Nine", "Equals", "81 ")]
[DataRow("Eight", "Multiply by", "Nine", "Equals", "72 ")]
[DataRow("Seven", "Multiply by", "Nine", "Equals", "63 ")]
[DataRow("Six", "Multiply by", "Nine", "Equals", "54 ")]
[DataRow("Five", "Multiply by", "Nine", "Equals", "45 ")]

public void Multiplication_Advanced(string input1, string operation, string input2, string equals, string assertion)
{
CalculatorSession.FindElementByName(input1).Click();
CalculatorSession.FindElementByName(operation).Click();
CalculatorSession.FindElementByName(input2).Click();
CalculatorSession.FindElementByName(equals).Click();
Assert.AreEqual("Display is " + assertion, CalculatorResult.Text);
}

[TestMethod]
[DataRow("Nine", "Minus", "Seven", "Equals", "2 ")]
[DataRow("Eight", "Minus", "Six", "Equals", "2 ")]
[DataRow("Seven", "Minus", "One", "Equals", "6 ")]
[DataRow("Six", "Minus", "Three", "Equals", "3 ")]
[DataRow("Five", "Minus", "Four", "Equals", "1 ")]
public void Subtraction_Advanced(string input1, string operation, string input2, string equals, string assertion)
{
CalculatorSession.FindElementByName(input1).Click();
CalculatorSession.FindElementByName(operation).Click();
CalculatorSession.FindElementByName(input2).Click();
CalculatorSession.FindElementByName(equals).Click();
Assert.AreEqual("Display is "+ assertion, CalculatorResult.Text);
}
}
}
19 changes: 12 additions & 7 deletions Samples/C#/CalculatorTest/CalculatorTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,18 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\MSTest.TestFramework.1.0.6-preview\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\MSTest.TestFramework.1.0.6-preview\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="WebDriver, Version=2.52.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Selenium.WebDriver.2.52.0\lib\net40\WebDriver.dll</HintPath>
<Reference Include="WebDriver, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Selenium.WebDriver.3.0.1\lib\net40\WebDriver.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
Expand All @@ -48,13 +56,10 @@
<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>
<Otherwise />
</Choose>
<ItemGroup>
<Compile Include="AdvancedScenarios.cs" />
<Compile Include="BasicScenarios.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down
6 changes: 4 additions & 2 deletions Samples/C#/CalculatorTest/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Selenium.WebDriver" version="2.52.0" targetFramework="net45" />
<package id="MSTest.TestAdapter" version="1.1.5-preview" targetFramework="net45" />
<package id="MSTest.TestFramework" version="1.0.6-preview" targetFramework="net45" />
<package id="Selenium.WebDriver" version="3.0.1" targetFramework="net45" />
</packages>
Loading

0 comments on commit c7f8dbd

Please sign in to comment.