Best WinAppDriver code snippet using UWPControls.TextBox.SendKeys
TextBox.cs
Source:TextBox.cs
...51 [TestMethod]52 public void Clear()53 {54 Assert.AreEqual(string.Empty, textBoxElement1.Text);55 textBoxElement1.SendKeys("fghij67890^&*()");56 Assert.AreEqual("fghij67890^&*()", textBoxElement1.Text);57 textBoxElement1.Clear();58 Assert.AreEqual(string.Empty, textBoxElement1.Text);59 }60 [TestMethod]61 public void Click()62 {63 // Click textBoxElement1 to set focus and arbitrarily type64 Assert.AreEqual(string.Empty, textBoxElement1.Text);65 textBoxElement1.Click();66 session.Keyboard.SendKeys("1234567890");67 Assert.AreEqual("1234567890", textBoxElement1.Text);68 // Click textBoxElement2 to set focus and arbitrarily type69 Assert.AreEqual(string.Empty, textBoxElement2.Text);70 textBoxElement2.Click();71 session.Keyboard.SendKeys("1234567890");72 Assert.AreEqual("1234567890", textBoxElement2.Text);73 }74 [TestMethod]75 public void Displayed()76 {77 Assert.IsTrue(textBoxElement1.Displayed);78 Assert.IsTrue(textBoxElement2.Displayed);79 }80 [TestMethod]81 public void Enabled()82 {83 Assert.IsTrue(textBoxElement1.Enabled);84 Assert.IsTrue(textBoxElement2.Enabled);85 }86 [TestMethod]87 public void Location()88 {89 Assert.IsTrue(textBoxElement2.Location.X >= textBoxElement1.Location.X);90 Assert.IsTrue(textBoxElement2.Location.Y >= textBoxElement1.Location.Y);91 }92 [TestMethod]93 public void LocationInView()94 {95 Assert.IsTrue(textBoxElement2.LocationOnScreenOnceScrolledIntoView.X >= textBoxElement1.LocationOnScreenOnceScrolledIntoView.X);96 Assert.IsTrue(textBoxElement2.LocationOnScreenOnceScrolledIntoView.Y >= textBoxElement1.LocationOnScreenOnceScrolledIntoView.Y);97 }98 [TestMethod]99 public void Name()100 {101 Assert.AreEqual("ControlType.Edit", textBoxElement1.TagName);102 Assert.AreEqual("ControlType.Edit", textBoxElement2.TagName);103 }104 [TestMethod]105 public void SendKeys()106 {107 Assert.AreEqual(string.Empty, textBoxElement1.Text);108 textBoxElement1.SendKeys("abcde12345!@#$%");109 Assert.AreEqual("abcde12345!@#$%", textBoxElement1.Text);110 // Use Ctrl + A to select all text and backspace to clear the box111 textBoxElement1.SendKeys(Keys.Control + "a" + Keys.Control + Keys.Backspace);112 Assert.AreEqual(string.Empty, textBoxElement1.Text);113 Assert.AreEqual(string.Empty, textBoxElement2.Text);114 textBoxElement2.SendKeys("fghij67890^&*()");115 Assert.AreEqual("fghij67890^&*()", textBoxElement2.Text);116 }117 [TestMethod]118 public void Size()119 {120 Assert.IsTrue(textBoxElement1.Size.Width > 0);121 Assert.IsTrue(textBoxElement1.Size.Height > 0);122 Assert.IsTrue(textBoxElement2.Size.Width >= textBoxElement1.Size.Width);123 Assert.IsTrue(textBoxElement2.Size.Height >= textBoxElement1.Size.Height);124 }125 [TestMethod]126 public void Text()127 {128 Assert.AreEqual(string.Empty, textBoxElement1.Text);129 textBoxElement1.SendKeys("abcde12345!@#$%");130 Assert.AreEqual("abcde12345!@#$%", textBoxElement1.Text);131 // Highlight the first 3 characters in the textBox132 textBoxElement1.SendKeys(Keys.Home + Keys.Shift + Keys.Right + Keys.Right + Keys.Right + Keys.Shift);133 Assert.AreEqual("abc", textBoxElement1.Text); // Only the highlighted characters should be returned134 // Use Ctrl + A to select all text135 textBoxElement1.SendKeys(Keys.Control + "a" + Keys.Control);136 Assert.AreEqual("abcde12345!@#$%", textBoxElement1.Text);137 }138 }139}...
SendKeys
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using Windows.UI.Xaml;7using Windows.UI.Xaml.Controls;8using Windows.UI.Xaml.Media;9using Windows.UI.Xaml.Media.Imaging;10using Windows.UI.Xaml.Shapes;11using Windows.UI.Xaml.Controls.Primitives;12using Windows.UI.Xaml.Input;13using Windows.UI.Xaml.Navigation;14using Windows.UI.Xaml.Documents;15using Windows.UI.Xaml.Data;16using Windows.UI;17using Windows.UI.Xaml.Media.Animation;18using Windows.UI.Xaml.Markup;19using Windows.UI.Xaml.Hosting;20using System.Reflection;21using System.IO;22using Windows.UI.Popups;23using Windows.UI.Core;24using Windows.Storage;25using Windows.Storage.Streams;26using Windows.Storage.Pickers;27using Windows.Foundation;28using Windows.UI.Xaml.Automation.Peers;29using Windows.UI.Xaml.Automation.Provider;30using Windows.UI.Xaml.Automation;31using Windows.UI.ViewManagement;32using Windows.UI.Input;33using Windows.UI.Xaml.Media.Animation;34using Windows.UI.Xaml.Media.Media3D;35using Windows.UI.Xaml.Media.Effects;36using Windows.UI.Xaml.Media.Imaging;37using Windows.UI.Xaml.Media;38using Windows.UI.Xaml.Controls.Primitives;39using Windows.UI.Xaml.Controls;40using Windows.UI.Xaml;41using Windows.UI;42using Windows.UI.Popups;43using Windows.UI.Core;44using Windows.UI.Xaml.Input;45using Windows.UI.Xaml.Navigation;46using Windows.UI.Xaml.Documents;47using Windows.UI.Xaml.Data;48using Windows.UI.Xaml.Media;49using Windows.UI.Xaml.Media.Animation;50using Windows.UI.Xaml.Markup;51using Windows.UI.Xaml.Hosting;52using System.Reflection;53using System.IO;54using System.Linq;55using System.Text;56using System.Threading.Tasks;57using System.Collections.Generic;58using System;59using System.ComponentModel;60using System.Runtime.CompilerServices;61using System.Runtime.InteropServices.WindowsRuntime;62using System.Threading;63using System.Threading.Tasks;64using System.Runtime.InteropServices;65using System;66using Windows.Foundation;67using Windows.Foundation.Collections;68using Windows.Foundation.Metadata;69using Windows.UI.Xaml;70using Windows.UI.Xaml.Controls;71using Windows.UI.Xaml.Input;72using Windows.UI.Xaml.Media;73using Windows.UI.Xaml.Media.Animation;74using Windows.UI.Xaml.Media.Imaging;75using Windows.UI.Xaml.Media.Media3D;76using Windows.UI.Xaml.Media.Effects;77using Windows.UI.Xaml.Shapes;78using Windows.UI.Xaml.Controls.Primitives;79using Windows.UI.Xaml.Automation.Peers;80using Windows.UI.Xaml.Automation.Provider;81using Windows.UI.Xaml.Automation;82using Windows.UI.ViewManagement;83using Windows.UI.Input;84using Windows.UI.Xaml.Documents;85using Windows.UI.Xaml.Data;86using Windows.UI.Xaml.Hosting;
SendKeys
Using AI Code Generation
1using System;2using System.Windows.Forms;3using UWPControls;4{5 {6 public Form1()7 {8 InitializeComponent();9 }10 private void button1_Click(object sender, EventArgs e)11 {12 textBox1.SendKeys("Hello World");13 }14 }15}16 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click17 TextBox1.SendKeys("Hello World")18using System;19using System.Windows.Forms;20using UWPControls;21{22 {23 public Form1()24 {25 InitializeComponent();26 }27 private void button1_Click(object sender, EventArgs e)28 {29 textBox1.SelectionLength = 5;30 }31 }32}33 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click34using System;35using System.Windows.Forms;36using UWPControls;37{38 {39 public Form1()40 {41 InitializeComponent();42 }43 private void button1_Click(object sender, EventArgs e)44 {45 textBox1.SelectionStart = 5;46 }47 }48}49 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click50using System;51using System.Windows.Forms;52using UWPControls;53{54 {
SendKeys
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using Windows.UI.Xaml.Controls;7using Windows.UI.Xaml.Input;8using Windows.UI.Xaml;9using Windows.UI.Xaml.Automation.Peers;10using Windows.UI.Xaml.Automation.Provider;11using Windows.UI.Xaml.Automation;12using Windows.UI.Xaml.Media;13using Windows.UI;14using Windows.Foundation;15using Windows.UI.Xaml.Shapes;16using Windows.UI.Xaml.Media.Animation;17using Windows.UI.Xaml.Media.Imaging;18using Windows.UI.Xaml.Navigation;19using Windows.UI.Xaml.Controls.Primitives;20using Windows.UI.Xaml.Data;21using Windows.UI.Xaml.Documents;22using Windows.UI.Xaml.Hosting;23using Windows.UI.Xaml.Markup;24using Windows.UI.Xaml.Media;25using Windows.UI.Xaml.Media.Media3D;26using Windows.UI.Xaml.Media.Animation;27using Windows.UI.Xaml.Navigation;28using Windows.UI.Xaml.Resources;29using Windows.UI.Xaml.Shapes;30using Windows.UI.Xaml.Controls;31using Windows.UI.Xaml.Controls.Primitives;32using Windows.UI.Xaml.Automation.Peers;33using Windows.UI.Xaml.Automation.Provider;34using Windows.UI.Xaml.Automation;35using Windows.UI.Xaml.Data;36using Windows.UI.Xaml.Documents;37using Windows.UI.Xaml.Input;38using Windows.UI.Xaml.Media;39using Windows.UI.Xaml.Media.Animation;40using Windows.UI.Xaml.Media.Imaging;41using Windows.UI.Xaml.Navigation;42using Windows.UI.Xaml.Resources;43using Windows.UI.Xaml.Shapes;44using Windows.UI.Xaml.Controls;45using Windows.UI.Xaml.Controls.Primitives;46using Windows.UI.Xaml.Automation.Peers;47using Windows.UI.Xaml.Automation.Provider;48using Windows.UI.Xaml.Automation;49using Windows.UI.Xaml.Data;50using Windows.UI.Xaml.Documents;51using Windows.UI.Xaml.Input;52using Windows.UI.Xaml.Media;53using Windows.UI.Xaml.Media.Animation;54using Windows.UI.Xaml.Media.Imaging;55using Windows.UI.Xaml.Navigation;56using Windows.UI.Xaml.Resources;57using Windows.UI.Xaml.Shapes;58using Windows.UI.Xaml.Controls;59using Windows.UI.Xaml.Controls.Primitives;60using Windows.UI.Xaml.Automation.Peers;61using Windows.UI.Xaml.Automation.Provider;62using Windows.UI.Xaml.Automation;63using Windows.UI.Xaml.Data;64using Windows.UI.Xaml.Documents;65using Windows.UI.Xaml.Input;66using Windows.UI.Xaml.Media;67using Windows.UI.Xaml.Media.Animation;68using Windows.UI.Xaml.Media.Imaging;69using Windows.UI.Xaml.Navigation;70using Windows.UI.Xaml.Resources;71using Windows.UI.Xaml.Shapes;72using Windows.UI.Xaml.Controls;73using Windows.UI.Xaml.Controls.Primitives;74using Windows.UI.Xaml.Automation.Peers;75using Windows.UI.Xaml.Automation.Provider;76using Windows.UI.Xaml.Automation;77using Windows.UI.Xaml.Data;78using Windows.UI.Xaml.Documents;79using Windows.UI.Xaml.Input;
SendKeys
Using AI Code Generation
1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using Windows.UI.Xaml.Controls;7using Windows.UI.Xaml.Input;8using Windows.UI.Xaml;9using Windows.UI.Xaml.Media;10using Windows.UI;11using Windows.UI.Xaml.Shapes;12using Windows.UI.Xaml.Media.Imaging;13using Windows.UI.Xaml.Automation.Peers;14using Windows.UI.Xaml.Automation.Provider;15using Windows.UI.Xaml.Automation;16using Windows.UI.Xaml.Controls.Primitives;17using Windows.UI.Xaml.Navigation;18using Windows.UI.Popups;19using Windows.UI.Core;20using Windows.Foundation;21using Windows.Foundation.Collections;22using Windows.UI.Xaml.Data;23{24 {25 public MainPage()26 {27 this.InitializeComponent();28 }29 private void TextBox1_KeyDown(object sender, KeyRoutedEventArgs e)30 {31 if (e.Key == Windows.System.VirtualKey.Enter)32 {33 TextBox1.SendKeys(TextBox2.Text);34 TextBox2.Text = "";35 }36 }37 }38}
SendKeys
Using AI Code Generation
1using System;2using Windows.UI.Xaml;3using Windows.UI.Xaml.Controls;4using Windows.UI.Xaml.Input;5using Windows.UI.Xaml.Navigation;6using Windows.UI.Xaml.Controls.Primitives;7using Windows.UI.Xaml.Automation.Peers;8using Windows.UI.Xaml.Automation.Provider;9using Windows.UI.Xaml.Automation;10using Windows.UI.Xaml.Media;11using Windows.UI;12using Windows.UI.Xaml.Shapes;13using System.Text;14using Windows.UI.Xaml.Media.Imaging;15using Windows.UI.Xaml.Media.Animation;16using Windows.UI.Xaml.Data;17using Windows.UI.Xaml.Markup;18using Windows.UI.Xaml.Documents;19using Windows.UI.Xaml.Hosting;20using Windows.UI.Core;21using Windows.UI.ViewManagement;22using Windows.UI.Popups;23using Windows.UI.Notifications;24using Windows.Data.Xml.Dom;25using Windows.Storage;26using Windows.Storage.Streams;27using Windows.Storage.Pickers;28using Windows.Storage.Provider;29using Windows.ApplicationModel.DataTransfer;30using Windows.ApplicationModel.DataTransfer.ShareTarget;31using Windows.ApplicationModel.DataTransfer.DragDrop;32using Windows.ApplicationModel.DataTransfer.DragDrop.Core;33using Windows.Foundation;34using Windows.Foundation.Collections;35using Windows.Foundation.Metadata;36using Windows.ApplicationModel.Core;37using Windows.ApplicationModel.Activation;38using Windows.ApplicationModel;39using Windows.ApplicationModel.AppService;40using Windows.ApplicationModel.Background;41using Windows.ApplicationModel.Resources;42using Windows.ApplicationModel.Resources.Core;43using Windows.ApplicationModel.Resources.Management;44using Windows.Graphics.Display;45using Windows.Graphics.Imaging;46using Windows.Graphics.Printing;47using Windows.Graphics.Printing.OptionDetails;48using Windows.Graphics.Printing.PrintTicket;49using Windows.Graphics.Printing.Workflow;50using Windows.Graphics.Capture;51using Windows.Graphics.DirectX;52using Windows.Graphics.DirectX.Direct3D11;53using Windows.Graphics.Effects;54using Windows.Graphics.Holographic;55using Windows.Graphics.Imaging;56using Windows.Graphics.Printing;57using Windows.Graphics.Printing.OptionDetails;58using Windows.Graphics.Printing.PrintTicket;59using Windows.Graphics.Printing.Workflow;60using Windows.Graphics.Printing3D;61using Windows.Graphics.Printing3D.PrintTicket;62using Windows.Graphics.Printing3D.Workflow;63using Windows.Graphics.Printing3D.Workflow.ComponentModel;64using Windows.Graphics.Printing3D.Workflow.ObjectModel;65using Windows.Graphics.Printing3D.Workflow.PrintTicket;66using Windows.Graphics.Printing3D.Workflow.PrintTicket.Validation;67using Windows.Graphics.Printing3D.Workflow.PrintTicketExtensions;68using Windows.Graphics.Printing3D.Workflow.PrintTicketExtensions.Validation;69using Windows.Graphics.Printing3D.Workflow.PrintTicketValidation;
SendKeys
Using AI Code Generation
1using System;2 using System.Windows.Forms;3 using UWPControls;4{5 {6 static void Main( string [] args)7 {8 TextBox textBox = new TextBox();9 textBox.SendKeys( "Hello World" );10 Console.ReadKey();11 }12 }13}
SendKeys
Using AI Code Generation
1using System;2using System.Windows.Forms;3using UWPControls;4using System.Drawing;5{6 {7 static void Main(string[] args)8 {9 TextBox textBox = new TextBox();10 textBox.Location = new Point(10, 10);11 textBox.Text = "Hello World";12 textBox.Width = 200;13 textBox.Height = 100;14 textBox.SendKeys("{CTRL}a{BACKSPACE}");
SendKeys
Using AI Code Generation
1using System;2using UWPControls;3{4 {5 public static void Main(string[] args)6 {7 TextBox tb = new TextBox();8 tb.SendKeys("Hello World");9 }10 }11}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!