Interactions
Replacing text on a control
❌ Don't: Select and replace text with a double click
PageObject.TextBox.Click(MouseButton.Left, ClickType.Single);
PageObject.TextBox.Click(MouseButton.Left, ClickType.Double);
PageObject.TextBox.SendKeys("Hello World");✔️ Do: Use the control's Text property
PageObject.TextBox.Text = "Hello World";✔️ Do: Select and SendKeys in masked text boxes
PageObject.MaskedTextBox.SendKeys("[" + Keys.CTRL + "a]"); // Select all the text
PageObject.MaskedTextBox.SendKeys("maskedtext");Repeated step sequences
❌ Don't: Repeat step sequences in code
✔️ Do: Abstract repeated steps into page objects
✔️ Do: Abstract repeated steps into a private method
✔️ Do: Create a utility class with commonly used steps
Awaiting for the application to respond
❌ Don't: Use System.Threading.Thread.Sleep
❌ Don't: Use a try / catch to retry failed steps
✔️ Do: Simply use the framework
✔️ Do: Adjust the step and execution timeouts
✔️ Do: Use the Retry static class
Finding child controls
❌ Don't: Cast to a concrete implementation and use concrete methods
✔️ Do: Use the Find method
Last updated
Was this helpful?