Skip to content

Commit 4408105

Browse files
committed
touch ups after review on staging
1 parent 634cf5a commit 4408105

File tree

2 files changed

+32
-38
lines changed

2 files changed

+32
-38
lines changed

docs/test/set-a-unique-automation-property-for-windows-store-controls-for-testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Set the **AutomationProperties.Name** to **ButtonY** explicitly in the XAML for
4646
<Button AutomationProperties.Name="ButtonY" Height="31" HorizontalAlignment="Left" Margin="23,76,0,0" VerticalAlignment="Top" Width="140" Click="ButtonY_Click" />
4747
```
4848

49-
### Assign unique automation properties
49+
## Assign unique names
5050

5151
In Blend for Visual Studio, you can select an option to assign unique names to interactive elements such as buttons, list boxes, combo boxes, and text boxes. This gives the controls unique values for **AutomationProperties.Name**.
5252

docs/test/test-uwp-app-with-coded-ui-test.md

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,23 @@ This article explains how to create a coded UI test for a Universal Windows Plat
2121

2222
The first step is to create a simple UWP app to run the test against.
2323

24-
1. In Visual Studio, create a new project using the **Blank App (Universal Windows)** template for Visual C# or Visual Basic template.
24+
1. In Visual Studio, create a new project using the **Blank App (Universal Windows)** template for Visual C# or Visual Basic.
2525

2626
![Blank app Universal Windows template](../test/media/blank-uwp-app-template.png)
2727

2828
1. In the **New Universal Windows Platform Project** dialog, select **OK** to accept the default platform versions.
2929

3030
1. From **Solution Explorer**, open *MainPage.xaml*.
3131

32+
The file opens in the **XAML Designer**.
33+
3234
1. Drag a button control and a textbox control from **Toolbox** to the design surface.
3335

3436
![Design the UWP app](../test/media/toolbox-controls.png)
3537

36-
1. Give names to the controls. Select the textbox control and in the **Properties** window, enter **textBox** in the **Name** field. Then, select the button control and in the **Properties** window, enter **button** in the **Name** field.
38+
1. Give names to the controls. Select the textbox control, and then in the **Properties** window, enter **textBox** in the **Name** field. Select the button control, and then in the **Properties** window, enter **button** in the **Name** field.
3739

38-
1. Double-click the button control and add the following code to the body of the `Button_Click` method. This code sets the text in the textbox to the name of the button control.
40+
1. Double-click the button control and add the following code to the body of the `Button_Click` method. This code simply sets the text in the textbox to the name of the button control, just to give us something to verify with the coded UI test we'll create later.
3941

4042
```csharp
4143
this.textBox.Text = this.button.Name;
@@ -65,7 +67,7 @@ The first step is to create a simple UWP app to run the test against.
6567

6668
1. Open the **Coded UI Test Builder** dialog by placing the cursor in the `CodedUITestMethod1` method and then choosing **Test** > **Generate Code for Coded UI Test** > **Use Coded UI Test Builder**.
6769

68-
1. Use the **Coded UI Test Builder** cross-hair tool to select the button control in the UWP app. In the **Add Assertions** dialog, expand the **UI Control Map** pane if necessary, and then select **Add control to UI Control Map**.
70+
1. Add the controls to the UI control map. Use the **Coded UI Test Builder** cross-hair tool to select the button control in the UWP app. In the **Add Assertions** dialog, expand the **UI Control Map** pane if necessary, and then select **Add control to UI Control Map**.
6971

7072
![Add control to UI map](../test/media/add-control-to-ui-control-map.png)
7173

@@ -75,27 +77,25 @@ The first step is to create a simple UWP app to run the test against.
7577

7678
![Generate code for the UI map](../test/media/generate-code-dialog.png)
7779

78-
1. Click the button to verify that the text in the textbox is set to **button**.
80+
1. To verify that the text in the textbox changes to **button** when the button is clicked, click the button.
7981

8082
![Click button control to set textbox value](../test/media/uwp-app-button-textbox.png)
8183

82-
1. Use the cross-hair tool to select the textbox control, and then select the **Text** property in the **Add Assertions** dialog.
83-
84-
1. In the **Add Assertions** dialog, select **Add Assertion** or press **Alt**+**A**. The assertion verifies that the text value is correct. In the **Message on Assertion Failure** box, enter **Textbox value is unexpected.** and then select **OK**.
84+
1. Add an assertion to verify the text in the textbox control. Use the cross-hair tool to select the textbox control, and then select the **Text** property in the **Add Assertions** dialog. Then, select **Add Assertion** or press **Alt**+**A**. In the **Message on Assertion Failure** box, enter **Textbox value is unexpected.** and then select **OK**.
8585

8686
![Choose textbox with cross-hair and add assertion](../test/media/add-assertion-for-text.png)
8787

88-
1. In the **Coded UI Test Builder** dialog, select **Generate Code** to generate code for the assertion. In the **Generate Code** dialog, select **Add and Generate**.
88+
1. Generate test code for the assertion. In the **Coded UI Test Builder** dialog, select **Generate Code**. In the **Generate Code** dialog, select **Add and Generate**.
8989

9090
![Generate code for textbox assertion](../test/media/add-and-generate-assert-method.png)
9191

92-
1. In **Solution Explorer**, open *UIMap.Designer.cs* to view the added code for the assert method and the controls.
92+
In **Solution Explorer**, open *UIMap.Designer.cs* to view the added code for the assert method and the controls.
9393

9494
> [!TIP]
95-
> If you're using Visual Basic,open *CodedUITest1.vb*. Then, in the `CodedUITestMethod1()` test method code, right-click on the call to the assert method (`Me.UIMap.AssertMethod1()`) and choose **Go To Definition**. *UIMap.Designer.vb* opens in the code editor so you can view the added code for the assert method and the controls.
95+
> If you're using Visual Basic,open *CodedUITest1.vb*. Then, in the `CodedUITestMethod1()` test method code, right-click on the call to the assert method `Me.UIMap.AssertMethod1()` and choose **Go To Definition**. *UIMap.Designer.vb* opens in the code editor, and you can view the added code for the assert method and the controls.
9696
9797
> [!WARNING]
98-
> Do not modify the *UIMap.designer.cs* or *UIMap.Designer.vb* files directly. If you do, the changes to the file will be overwritten when the test is generated.
98+
> Do not modify the *UIMap.designer.cs* or *UIMap.Designer.vb* files directly. If you do, your changes will be overwritten when the test is generated.
9999
100100
The assert method looks like this:
101101

@@ -127,31 +127,29 @@ The first step is to create a simple UWP app to run the test against.
127127

128128
![AutomationID in Add Assertion dialog](../test/media/automation-id.png)
129129

130-
1. In **Solution Explorer**, open *CodedUITest1.cs* or *CodedUITest1.vb*. Add code to the `CodedUITestMethod1` method to launch the UWP app and then tap the button:
131-
132-
1. Above the called to `AssertMethod1`, add code to launch the UWP app:
130+
1. Add code to the test method to launch the UWP app. In **Solution Explorer**, open *CodedUITest1.cs* or *CodedUITest1.vb*. Above the called to `AssertMethod1`, add code to launch the UWP app:
133131

134-
```csharp
135-
XamlWindow.Launch("af5ecd75-f252-45a1-9e7e-c6f1d8f054ff_0q1pp7qrjexbp!App")
136-
```
132+
```csharp
133+
XamlWindow.Launch("af5ecd75-f252-45a1-9e7e-c6f1d8f054ff_0q1pp7qrjexbp!App")
134+
```
137135

138-
```vb
139-
XamlWindow myAppWindow = XamlWindow.Launch("af5ecd75-f252-45a1-9e7e-c6f1d8f054ff_0q1pp7qrjexbp!App");
140-
```
136+
```vb
137+
XamlWindow myAppWindow = XamlWindow.Launch("af5ecd75-f252-45a1-9e7e-c6f1d8f054ff_0q1pp7qrjexbp!App");
138+
```
141139

142-
Replace the automation ID in the example code with the value you copied to the clipboard in the previous step.
140+
Replace the automation ID in the example code with the value you copied to the clipboard in the previous step.
143141

144-
> [!IMPORTANT]
145-
> Trim the beginning of the automation ID to remove characters such as **P~**. If you don't trim these characters, the test throws a `Microsoft.VisualStudio.TestTools.UITest.Extension.PlaybackFailureException` when it tries to launch the app.
142+
> [!IMPORTANT]
143+
> Trim the beginning of the automation ID to remove characters such as **P~**. If you don't trim these characters, the test throws a `Microsoft.VisualStudio.TestTools.UITest.Extension.PlaybackFailureException` when it tries to launch the app.
146144
147-
2. On the next line, add a gesture to tap the button control:
145+
1. Next, add code to the test method to click the button. On the line after `XamlWindow.Launch`, add a gesture to tap the button control:
148146

149-
```csharp
150-
Gesture.Tap(this.UIMap.UIUWPAppWindow.UIButtonButton);
151-
```
147+
```csharp
148+
Gesture.Tap(this.UIMap.UIUWPAppWindow.UIButtonButton);
149+
```
152150

153-
```vb
154-
Gesture.Tap(Me.UIMap.UIUWPAppWindow.UIButtonButton)
151+
```vb
152+
Gesture.Tap(Me.UIMap.UIUWPAppWindow.UIButtonButton)
155153

156154
After adding the code, the complete `CodedUITestMethod1` test method should appear as follows:
157155

@@ -189,7 +187,7 @@ The first step is to create a simple UWP app to run the test against.
189187

190188
1. Select **Run All** to run the test.
191189

192-
The app opens, the button tap gesture executes, and the textbox's **Text** property is populated. The assert methods validates the textbox's **Text** property.
190+
The app opens, the button is tapped, and the textbox's **Text** property is populated. The assert method validates the textbox's **Text** property.
193191

194192
After the test completes, **Test Explorer** displays that the test passed.
195193

@@ -205,15 +203,11 @@ The first step is to create a simple UWP app to run the test against.
205203

206204
**A**: No, only XAML-based apps are supported.
207205

208-
### Q: Can I create coded UI tests for my UWP apps on a system that is not running Windows 8.1 or Windows 10?
209-
210-
**A**: No, the Coded UI Test Project templates are only available on Windows 8.1 and Windows 10. To create automation for Universal Windows Platform (UWP) apps, you'll need Windows 10.
211-
212206
### Q: Why can't I modify the code in the UIMap.Designer file?
213207

214-
**A**: Any code changes you make in the *UIMapDesigner.cs* file will be overwritten every time you generate code using the UIMap - Coded UI Test Builder. If you have to modify a recorded method, you must copy it to the *UIMap.cs* file and rename it. The *UIMap.cs* file can be used to override methods and properties in the *UIMapDesigner.cs* file. Remove the reference to the original method in the *CodedUITest.cs* file and replace it with the renamed method name.
208+
**A**: Any code changes you make in the *UIMapDesigner.cs* file are overwritten every time you generate code using the **Coded UI Test Builder**. If you have to modify a recorded method, copy it to the *UIMap.cs* file and rename it. The *UIMap.cs* file can be used to override methods and properties in the *UIMapDesigner.cs* file. Remove the reference to the original method in the *CodedUITest.cs* file and replace it with the renamed method name.
215209

216210
## See also
217211

218-
- [Use UI automation to test Your code](../test/use-ui-automation-to-test-your-code.md)
212+
- [Use UI automation to test your code](../test/use-ui-automation-to-test-your-code.md)
219213
- [Set unique automation properties for UWP controls](../test/set-a-unique-automation-property-for-windows-store-controls-for-testing.md)

0 commit comments

Comments
 (0)