Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.VisualStudio.TestTools.UITesting;
- using Microsoft.VisualStudio.TestTools.UITesting.WinControls;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- using Mouse = Microsoft.VisualStudio.TestTools.UITesting.Mouse;
- namespace CodedUITestProject8 {
- /// <summary>
- /// Simple sandbox app for testing MSAA controls, i.e. Windows Forms
- /// </summary>
- [CodedUITest]
- public class myCalcCodedUITest1 {
- /// <summary>
- /// Very simple test of a Windows Forms app containing a single button and a single text box.
- /// This was originally generated using the UI Test... what is it called? But with the noise of
- /// the endless Windows titles etc. removed.
- /// This is to be converted to a Page Pattern and more ambitiously will be technology agnostic.
- /// </summary>
- [TestMethod]
- public void AButtonIsClickedAndTextisEnteredInAnEditControl() {
- var simpleCalculator = ApplicationUnderTest.Launch(@"c:\temp\WindowsFormsApplication1.exe");
- var topLevelCalculatorWindow = new WinWindow(simpleCalculator);
- topLevelCalculatorWindow.SearchProperties.Add(new PropertyExpression(WinWindow.PropertyNames.ClassName,
- "WindowsForms10.Window", PropertyExpressionOperator.Contains));
- // Button...
- var buttonControl = new WinWindow(topLevelCalculatorWindow);
- buttonControl.SearchProperties[WinWindow.PropertyNames.ControlName] = "MybuttonControlName";
- var calcButton = new WinButton(buttonControl);
- calcButton.SearchProperties.Add(WinButton.PropertyNames.Name, "MyDisplayText");
- Mouse.Click(calcButton);
- // TextBox...
- var editControl = new WinWindow(topLevelCalculatorWindow);
- editControl.SearchProperties[WinWindow.PropertyNames.ControlName] = "textbox42";
- var textBox = new WinEdit(editControl);
- textBox.Text = "The way you were";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement