Skip to content

Commit 755e338

Browse files
authored
Merge pull request #750 from trashbat/fix-notepad-test
Workaround for issue #507 - notepad sample not correctly sending “/” on alternative keyboard layouts (e.g. UK and German)
2 parents d7a4969 + 9749d57 commit 755e338

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Samples/C#/NotepadTest/NotepadSession.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,7 @@ public void TestInitialize()
8181
editBox.SendKeys(Keys.Delete);
8282
Assert.AreEqual(string.Empty, editBox.Text);
8383
}
84+
85+
protected static string SanitizeBackslashes(string input) => input.Replace("\\", Keys.Alt + Keys.NumberPad9 + Keys.NumberPad2 + Keys.Alt);
8486
}
8587
}

Samples/C#/NotepadTest/ScenarioPopupDialog.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void PopupDialogSaveFile()
3636
session.FindElementByName("File").Click();
3737
session.FindElementByXPath($"//MenuItem[starts-with(@Name, \"Save As\")]").Click();
3838
Thread.Sleep(TimeSpan.FromSeconds(1)); // Wait for 1 second until the save dialog appears
39-
session.FindElementByAccessibilityId("FileNameControlHost").SendKeys(TargetSaveLocation + TestFileName);
39+
session.FindElementByAccessibilityId("FileNameControlHost").SendKeys(SanitizeBackslashes(TargetSaveLocation + TestFileName));
4040
session.FindElementByName("Save").Click();
4141

4242
// Check if the Save As dialog appears when there's a leftover test file from previous test run
@@ -70,7 +70,7 @@ public static void ClassCleanup()
7070
Assert.IsNotNull(windowsExplorerSession);
7171

7272
// Navigate Windows Explorer to the target save location folder
73-
windowsExplorerSession.Keyboard.SendKeys(Keys.Alt + "d" + Keys.Alt + TargetSaveLocation + Keys.Enter);
73+
windowsExplorerSession.Keyboard.SendKeys(Keys.Alt + "d" + Keys.Alt + SanitizeBackslashes(TargetSaveLocation) + Keys.Enter);
7474

7575
// Verify that the file is indeed saved in the working directory and delete it
7676
windowsExplorerSession.FindElementByAccessibilityId("SearchEditBox").SendKeys(TestFileName + Keys.Enter);

0 commit comments

Comments
 (0)