Skip to content

Commit 218cb73

Browse files
committed
Update NotepadTest sample to address reliability issues
Update NotepadTest README.md with new running requirements and steps Update NotepadTest to use more recent NuGet packages
1 parent abf7eb7 commit 218cb73

File tree

5 files changed

+33
-26
lines changed

5 files changed

+33
-26
lines changed

Samples/C#/NotepadTest/NotepadSession.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static void Setup(TestContext context)
4646
Assert.AreEqual("Untitled - Notepad", session.Title);
4747

4848
// Set implicit timeout to 1.5 seconds to make element search to retry every 500 ms for at most three times
49-
session.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1.5));
49+
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5);
5050

5151
// Keep track of the edit box to be used throughout the session
5252
editBox = session.FindElementByClassName("Edit");

Samples/C#/NotepadTest/NotepadTest.csproj

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,11 @@
3838
<WarningLevel>4</WarningLevel>
3939
</PropertyGroup>
4040
<ItemGroup>
41-
<Reference Include="appium-dotnet-driver, Version=3.0.0.1, Culture=neutral, processorArchitecture=MSIL">
42-
<HintPath>packages\Appium.WebDriver.3.0.0.1\lib\net45\appium-dotnet-driver.dll</HintPath>
43-
<Private>True</Private>
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>
4443
</Reference>
45-
<Reference Include="Castle.Core">
46-
<HintPath>packages\Castle.Core.4.0.0-beta002\lib\net45\Castle.Core.dll</HintPath>
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>
4746
</Reference>
4847
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
4948
<HintPath>packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
@@ -53,18 +52,17 @@
5352
<HintPath>packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
5453
<Private>True</Private>
5554
</Reference>
56-
<Reference Include="Newtonsoft.Json">
57-
<HintPath>packages\Newtonsoft.Json.9.0.2-beta1\lib\net45\Newtonsoft.Json.dll</HintPath>
55+
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
56+
<HintPath>packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
5857
</Reference>
5958
<Reference Include="System" />
59+
<Reference Include="System.Configuration" />
6060
<Reference Include="System.Drawing" />
61-
<Reference Include="WebDriver, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
62-
<HintPath>packages\Selenium.WebDriver.3.0.1\lib\net40\WebDriver.dll</HintPath>
63-
<Private>True</Private>
61+
<Reference Include="WebDriver, Version=3.8.0.0, Culture=neutral, processorArchitecture=MSIL">
62+
<HintPath>packages\Selenium.WebDriver.3.8.0\lib\net45\WebDriver.dll</HintPath>
6463
</Reference>
65-
<Reference Include="WebDriver.Support, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
66-
<HintPath>packages\Selenium.Support.3.0.1\lib\net40\WebDriver.Support.dll</HintPath>
67-
<Private>True</Private>
64+
<Reference Include="WebDriver.Support, Version=3.8.0.0, Culture=neutral, processorArchitecture=MSIL">
65+
<HintPath>packages\Selenium.Support.3.8.0\lib\net45\WebDriver.Support.dll</HintPath>
6866
</Reference>
6967
</ItemGroup>
7068
<Choose>

Samples/C#/NotepadTest/README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,23 @@ This test project highlights some common interactions below that can be put toge
1414

1515
## Requirements
1616

17-
- Windows 10 PC with the latest Windows 10 version (Version 1607 or later)
18-
- Microsoft Visual Studio 2015 or later
17+
- Windows 10 PC with the latest Windows 10 version (Version 1809 or later)
18+
- Microsoft Visual Studio 2017 or later
1919

2020

2121
## Getting Started
2222

23-
1. Open `NotepadTest.sln` in Visual Studio
24-
2. Select **Test** > **Windows** > **Test Explorer**
25-
3. Select **Run All** on the test pane or through menu **Test** > **Run** > **All Tests**
23+
1. [Run](../../../README.md#installing-and-running-windows-application-driver) `WinAppDriver.exe` on the test device
24+
2. Open `NotepadTest.sln` in Visual Studio
25+
3. Select **Build** > **Rebuild Solution**
26+
4. Select **Test** > **Windows** > **Test Explorer**
27+
5. Select **Run All** on the test pane or through menu **Test** > **Run** > **All Tests**
2628

2729
> Once the project is successfully built, you can use the **TestExplorer** to pick and choose the test scenario(s) to run
2830
31+
> If Visual Studio fail to discover and run the test scenarios:
32+
> 1. Select **Tools** > **Options...** > **Test**
33+
> 2. Under *Active Solution*, uncheck *For improved performance, only use test adapters in test assembly folder or as specified in runsettings file*
2934
3035
## Adding/Updating Test Scenario
3136

Samples/C#/NotepadTest/ScenarioPopupDialog.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class ScenarioPopupDialog : NotepadSession
3434
public void PopupDialogSaveFile()
3535
{
3636
session.FindElementByName("File").Click();
37-
session.FindElementByName("Save As...").Click();
37+
session.FindElementByXPath($"//MenuItem[starts-with(@Name, \"Save As\")]").Click();
3838
Thread.Sleep(TimeSpan.FromSeconds(1)); // Wait for 1 second until the save dialog appears
3939
session.FindElementByAccessibilityId("FileNameControlHost").SendKeys(TargetSaveLocation + TestFileName);
4040
session.FindElementByName("Save").Click();
@@ -82,7 +82,11 @@ public static void ClassCleanup()
8282
}
8383
catch
8484
{
85-
testFileEntry = windowsExplorerSession.FindElementByName("Items View").FindElementByName(TestFileName) as WindowsElement;
85+
try
86+
{
87+
testFileEntry = windowsExplorerSession.FindElementByName("Items View").FindElementByName(TestFileName) as WindowsElement;
88+
}
89+
catch { }
8690
}
8791

8892
// Delete the test file when it exists
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Appium.WebDriver" version="3.0.0.1" targetFramework="net45" />
4-
<package id="Castle.Core" version="4.0.0-beta002" targetFramework="net45" />
3+
<package id="Castle.Core" version="4.2.1" targetFramework="net45" />
4+
<package id="Microsoft.WinAppDriver.Appium.WebDriver" version="1.0.1-Preview" targetFramework="net45" />
55
<package id="MSTest.TestAdapter" version="1.2.0" targetFramework="net45" />
66
<package id="MSTest.TestFramework" version="1.2.0" targetFramework="net45" />
7-
<package id="Newtonsoft.Json" version="9.0.2-beta1" targetFramework="net45" />
8-
<package id="Selenium.Support" version="3.0.1" targetFramework="net45" />
9-
<package id="Selenium.WebDriver" version="3.0.1" targetFramework="net45" />
7+
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" />
8+
<package id="Selenium.Support" version="3.8.0" targetFramework="net45" />
9+
<package id="Selenium.WebDriver" version="3.8.0" targetFramework="net45" />
1010
</packages>

0 commit comments

Comments
 (0)