Skip to content

Commit

Permalink
Merge pull request #750 from trashbat/fix-notepad-test
Browse files Browse the repository at this point in the history
Workaround for issue #507 - notepad sample not correctly sending “/” on alternative keyboard layouts (e.g. UK and German)
  • Loading branch information
hassanuz authored Jul 11, 2019
2 parents d7a4969 + 9749d57 commit 755e338
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Samples/C#/NotepadTest/NotepadSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,7 @@ public void TestInitialize()
editBox.SendKeys(Keys.Delete);
Assert.AreEqual(string.Empty, editBox.Text);
}

protected static string SanitizeBackslashes(string input) => input.Replace("\\", Keys.Alt + Keys.NumberPad9 + Keys.NumberPad2 + Keys.Alt);
}
}
4 changes: 2 additions & 2 deletions Samples/C#/NotepadTest/ScenarioPopupDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void PopupDialogSaveFile()
session.FindElementByName("File").Click();
session.FindElementByXPath($"//MenuItem[starts-with(@Name, \"Save As\")]").Click();
Thread.Sleep(TimeSpan.FromSeconds(1)); // Wait for 1 second until the save dialog appears
session.FindElementByAccessibilityId("FileNameControlHost").SendKeys(TargetSaveLocation + TestFileName);
session.FindElementByAccessibilityId("FileNameControlHost").SendKeys(SanitizeBackslashes(TargetSaveLocation + TestFileName));
session.FindElementByName("Save").Click();

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

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

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

0 comments on commit 755e338

Please sign in to comment.