How to use Notepad class of AbsoluteXPath package

Best WinAppDriver code snippet using AbsoluteXPath.Notepad

notepad.cs

Source:notepad.cs Github

copy

Full Screen

...18using OpenQA.Selenium;19namespace AbsoluteXPath20{21 [TestClass]22 public class Notepad23 {24 [TestMethod]25 public void TestMethod1()26 {27 DesktopSession desktopSession = new DesktopSession();28 TimeSpan.FromSeconds(2);29 bool bTestSuccess = false;30 try31 {32 // LeftClick on Button "Type here to search" at (85,17)33 Console.WriteLine("LeftClick on Button \"Type here to search\" at (85,17)");34 string xpath_LeftClickButtonTypehereto_85_17 = "/Pane[@ClassName=\"#32769\"][@Name=\"Desktop 1\"]/Pane[@ClassName=\"Shell_TrayWnd\"][@Name=\"Taskbar\"]/Pane[@ClassName=\"TrayDummySearchControl\"]/Button[@ClassName=\"Button\"][@Name=\"Type here to search\"]";35 var winElem_LeftClickButtonTypehereto_85_17 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftClickButtonTypehereto_85_17);36 if (winElem_LeftClickButtonTypehereto_85_17 != null)37 {38 winElem_LeftClickButtonTypehereto_85_17.Click();39 }40 else41 {42 Console.WriteLine($"Failed to find element using xpath: {xpath_LeftClickButtonTypehereto_85_17}");43 return;44 }45 // KeyboardInput VirtualKeys=""notepad"" CapsLock=False NumLock=False ScrollLock=False46 Console.WriteLine("KeyboardInput VirtualKeys=\"\"notepad\"\" CapsLock=False NumLock=False ScrollLock=False");47 System.Threading.Thread.Sleep(1000);48 winElem_LeftClickButtonTypehereto_85_17.SendKeys("notepad");49 // LeftClick on ListItem "Notepad, Desktop app, Press right to switch preview" at (46,32)50 Console.WriteLine("LeftClick on ListItem \"Notepad, Desktop app, Press right to switch preview\" at (46,32)");51 string xpath_LeftClickListItemNotepadDes_46_32 = "/Pane[@ClassName=\"#32769\"][@Name=\"Desktop 1\"]/Window[@ClassName=\"Windows.UI.Core.CoreWindow\"][@Name=\"Cortana\"]/Pane[@ClassName=\"WebView\"][@Name=\"Bing\"]/Pane[@Name=\"Bing\"]/List[@Name=\"Results\"][@AutomationId=\"suggestionsList\"]/ListItem[@Name=\"Notepad, Desktop app, Press right to switch preview\"][starts-with(@AutomationId,\"id_\")]";52 var winElem_LeftClickListItemNotepadDes_46_32 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftClickListItemNotepadDes_46_32);53 if (winElem_LeftClickListItemNotepadDes_46_32 != null)54 {55 winElem_LeftClickListItemNotepadDes_46_32.Click();56 }57 else58 {59 Console.WriteLine($"Failed to find element using xpath: {xpath_LeftClickListItemNotepadDes_46_32}");60 return;61 }62 // LeftClick on Document "Text Editor" at (143,95)63 Console.WriteLine("LeftClick on Document \"Text Editor\" at (143,95)");64 string xpath_LeftClickDocumentTextEditor_143_95 = "/Pane[@ClassName=\"#32769\"][@Name=\"Desktop 1\"]/Window[@ClassName=\"Notepad\"][contains(@Name,\"Untitled\")]/Document[@ClassName=\"Edit\"][@Name=\"Text Editor\"]";65 var winElem_LeftClickDocumentTextEditor_143_95 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftClickDocumentTextEditor_143_95);66 if (winElem_LeftClickDocumentTextEditor_143_95 != null)67 {68 winElem_LeftClickDocumentTextEditor_143_95.Click();69 }70 else71 {72 Console.WriteLine($"Failed to find element using xpath: {xpath_LeftClickDocumentTextEditor_143_95}");73 return;74 }75 // KeyboardInput VirtualKeys=""test"" CapsLock=False NumLock=False ScrollLock=False76 Console.WriteLine("KeyboardInput VirtualKeys=\"\"test\"\" CapsLock=False NumLock=False ScrollLock=False");77 System.Threading.Thread.Sleep(100);78 winElem_LeftClickDocumentTextEditor_143_95.SendKeys("test");79 Console.WriteLine("KeyboardInput VirtualKeys=\"Alt + F\" CapsLock=False NumLock=False ScrollLock=False");80 System.Threading.Thread.Sleep(1000);81 winElem_LeftClickDocumentTextEditor_143_95.SendKeys(Keys.Alt + "F" + Keys.Alt);82 // LeftClick on MenuItem "Save As..." at (62,17)83 Console.WriteLine("LeftClick on MenuItem \"Save As...\" at (62,17)");84 string xpath_LeftClickMenuItemSaveAs_62_17 = "/Pane[@ClassName=\"#32769\"][@Name=\"Desktop 1\"]/Window[@ClassName=\"Notepad\"][contains(@Name,\"Untitled\")]/Menu[@ClassName=\"#32768\"][@Name=\"File\"]/MenuItem[@Name=\"Save As...\"]";85 var winElem_LeftClickMenuItemSaveAs_62_17 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftClickMenuItemSaveAs_62_17);86 if (winElem_LeftClickMenuItemSaveAs_62_17 != null)87 {88 winElem_LeftClickMenuItemSaveAs_62_17.Click();89 }90 else91 {92 Console.WriteLine($"Failed to find element using xpath: {xpath_LeftClickMenuItemSaveAs_62_17}");93 return;94 }95 // LeftClick on Edit "File name:" at (147,11)96 Console.WriteLine("LeftClick on Edit \"File name:\" at (147,11)");97 string xpath_LeftClickEditFilename_147_11 = "/Pane[@ClassName=\"#32769\"][@Name=\"Desktop 1\"]/Window[@ClassName=\"Notepad\"][contains(@Name,\"Untitled\")]/Window[@ClassName=\"#32770\"][@Name=\"Save As\"]/Pane[@ClassName=\"DUIViewWndClassName\"]/ComboBox[@Name=\"File name:\"][@AutomationId=\"FileNameControlHost\"]/Edit[@ClassName=\"Edit\"][@Name=\"File name:\"]";98 var winElem_LeftClickEditFilename_147_11 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftClickEditFilename_147_11);99 if (winElem_LeftClickEditFilename_147_11 != null)100 {101 winElem_LeftClickEditFilename_147_11.Click();102 }103 else104 {105 Console.WriteLine($"Failed to find element using xpath: {xpath_LeftClickEditFilename_147_11}");106 return;107 }108 // KeyboardInput VirtualKeys="Keys.Backspace + Keys.BackspaceKeys.Backspace + Keys.BackspaceKeys.Backspace + Keys.BackspaceKeys.Backspace + Keys.BackspaceKeys.Backspace + Keys.Backspace"winappdrivertest.txt"" CapsLock=False NumLock=False ScrollLock=False109 Console.WriteLine("KeyboardInput VirtualKeys=\"Keys.Backspace + Keys.BackspaceKeys.Backspace + Keys.BackspaceKeys.Backspace + Keys.BackspaceKeys.Backspace + Keys.BackspaceKeys.Backspace + Keys.Backspace\"winappdrivertest.txt\"\" CapsLock=False NumLock=False ScrollLock=False");110 System.Threading.Thread.Sleep(100);111 winElem_LeftClickEditFilename_147_11.SendKeys(Keys.Backspace + Keys.Backspace);112 winElem_LeftClickEditFilename_147_11.SendKeys(Keys.Backspace + Keys.Backspace);113 winElem_LeftClickEditFilename_147_11.SendKeys(Keys.Backspace + Keys.Backspace);114 winElem_LeftClickEditFilename_147_11.SendKeys(Keys.Backspace + Keys.Backspace);115 winElem_LeftClickEditFilename_147_11.SendKeys(Keys.Backspace + Keys.Backspace);116 winElem_LeftClickEditFilename_147_11.SendKeys("1winappdrivertest.txt");117 // LeftClick on Button "Save" at (22,14)118 Console.WriteLine("LeftClick on Button \"Save\" at (22,14)");119 string xpath_LeftClickButtonSave_22_14 = "/Pane[@ClassName=\"#32769\"][@Name=\"Desktop 1\"]/Window[@ClassName=\"Notepad\"][contains(@Name,\"Untitled\")]/Window[@ClassName=\"#32770\"][@Name=\"Save As\"]/Button[@ClassName=\"Button\"][@Name=\"Save\"]";120 var winElem_LeftClickButtonSave_22_14 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftClickButtonSave_22_14);121 if (winElem_LeftClickButtonSave_22_14 != null)122 {123 winElem_LeftClickButtonSave_22_14.Click();124 }125 else126 {127 Console.WriteLine($"Failed to find element using xpath: {xpath_LeftClickButtonSave_22_14}");128 return;129 }130 Console.WriteLine("KeyboardInput VirtualKeys=\"Alt + F\" CapsLock=False NumLock=False ScrollLock=False");131 System.Threading.Thread.Sleep(1000);132 winElem_LeftClickDocumentTextEditor_143_95.SendKeys(Keys.Alt + "F" + Keys.Alt);133 // LeftClick on MenuItem "Open..." at (44,11)134 Console.WriteLine("LeftClick on MenuItem \"Open...\" at (44,11)");135 string xpath_LeftClickMenuItemOpen_44_11 = "/Pane[@ClassName=\"#32769\"][@Name=\"Desktop 1\"]/Window[@ClassName=\"Notepad\"][contains(@Name,\"1winappdrivertest\")]/Menu[@ClassName=\"#32768\"][@Name=\"File\"]/MenuItem[@Name=\"Open...\"]";136 var winElem_LeftClickMenuItemOpen_44_11 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftClickMenuItemOpen_44_11);137 if (winElem_LeftClickMenuItemOpen_44_11 != null)138 {139 winElem_LeftClickMenuItemOpen_44_11.Click();140 }141 else142 {143 Console.WriteLine($"Failed to find element using xpath: {xpath_LeftClickMenuItemOpen_44_11}");144 return;145 }146 // RightClick on Edit "Name" at (9,8)147 Console.WriteLine("RightClick on Edit \"Name\" at (9,8)");148 string xpath_RightClickEditName_9_8 = "/Pane[@ClassName=\"#32769\"][@Name=\"Desktop 1\"]/Window[@ClassName=\"Notepad\"][contains(@Name,\"1winappdrivertest\")]/Window[@ClassName=\"#32770\"][@Name=\"Open\"]/Pane[@ClassName=\"DUIViewWndClassName\"]/Pane[@Name=\"Shell Folder View\"][@AutomationId=\"listview\"]/List[@ClassName=\"UIItemsView\"][@Name=\"Items View\"]/ListItem[@ClassName=\"UIItem\"][@Name=\"1winappdrivertest.txt\"]/Edit[@Name=\"Name\"][@AutomationId=\"System.ItemNameDisplay\"]";149 var winElem_RightClickEditName_9_8 = desktopSession.FindElementByAbsoluteXPath(xpath_RightClickEditName_9_8);150 if (winElem_RightClickEditName_9_8 != null)151 {152 winElem_RightClickEditName_9_8.Click();153 desktopSession.DesktopSessionElement.Mouse.MouseMove(winElem_RightClickEditName_9_8.Coordinates);154 desktopSession.DesktopSessionElement.Mouse.ContextClick(null);155 }156 else157 {158 Console.WriteLine($"Failed to find element using xpath: {xpath_RightClickEditName_9_8}");159 return;160 }161 // LeftClick on MenuItem "Delete" at (71,5)162 Console.WriteLine("LeftClick on MenuItem \"Delete\" at (71,5)");163 string xpath_LeftClickMenuItemDelete_71_5 = "/Pane[@ClassName=\"#32769\"][@Name=\"Desktop 1\"]/Menu[@ClassName=\"#32768\"][@Name=\"Context\"]/MenuItem[@Name=\"Delete\"]";164 var winElem_LeftClickMenuItemDelete_71_5 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftClickMenuItemDelete_71_5);165 if (winElem_LeftClickMenuItemDelete_71_5 != null)166 {167 winElem_LeftClickMenuItemDelete_71_5.Click();168 }169 else170 {171 Console.WriteLine($"Failed to find element using xpath: {xpath_LeftClickMenuItemDelete_71_5}");172 return;173 }174 // LeftClick on Button "Cancel" at (24,13)175 Console.WriteLine("LeftClick on Button \"Cancel\" at (24,13)");176 string xpath_LeftClickButtonCancel_24_13 = "/Pane[@ClassName=\"#32769\"][@Name=\"Desktop 1\"]/Window[@ClassName=\"Notepad\"][contains(@Name,\"1winappdrivertest\")]/Window[@ClassName=\"#32770\"][@Name=\"Open\"]/Button[@ClassName=\"Button\"][@Name=\"Cancel\"]";177 var winElem_LeftClickButtonCancel_24_13 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftClickButtonCancel_24_13);178 if (winElem_LeftClickButtonCancel_24_13 != null)179 {180 winElem_LeftClickButtonCancel_24_13.Click();181 }182 else183 {184 Console.WriteLine($"Failed to find element using xpath: {xpath_LeftClickButtonCancel_24_13}");185 return;186 }187 // LeftClick on Button "Close" at (28,15)188 Console.WriteLine("LeftClick on Button \"Close\" at (28,15)");189 string xpath_LeftClickButtonClose_28_15 = "/Pane[@ClassName=\"#32769\"][@Name=\"Desktop 1\"]/Window[@ClassName=\"Notepad\"][contains(@Name,\"1winappdrivertest\")]/TitleBar[@AutomationId=\"TitleBar\"]/Button[@Name=\"Close\"]";190 var winElem_LeftClickButtonClose_28_15 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftClickButtonClose_28_15);191 if (winElem_LeftClickButtonClose_28_15 != null)192 {193 winElem_LeftClickButtonClose_28_15.Click();194 }195 else196 {197 Console.WriteLine($"Failed to find element using xpath: {xpath_LeftClickButtonClose_28_15}");198 return;199 }200 bTestSuccess = true;201 }202 finally203 {...

Full Screen

Full Screen

Notepad

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using AbsoluteXPath;7{8 {9 public void Open()10 {11 Console.WriteLine("Notepad is opened");12 }13 public void Close()14 {15 Console.WriteLine("Notepad is closed");16 }17 }18}19using System;20using System.Collections.Generic;21using System.Linq;22using System.Text;23using System.Threading.Tasks;24using AbsoluteXPath;25{26 {27 public void Open()28 {29 Console.WriteLine("Notepad is opened");30 }31 public void Close()32 {33 Console.WriteLine("Notepad is closed");34 }35 }36}37using System;38using System.Collections.Generic;39using System.Linq;40using System.Text;41using System.Threading.Tasks;42using AbsoluteXPath;43{44 {45 public void Open()46 {47 Console.WriteLine("Notepad is opened");48 }49 public void Close()50 {51 Console.WriteLine("Notepad is closed");52 }53 }54}55using System;56using System.Collections.Generic;57using System.Linq;58using System.Text;59using System.Threading.Tasks;60using AbsoluteXPath;61{62 {63 public void Open()64 {65 Console.WriteLine("Notepad is opened");66 }67 public void Close()68 {69 Console.WriteLine("Notepad is closed");70 }71 }72}73using System;74using System.Collections.Generic;75using System.Linq;76using System.Text;77using System.Threading.Tasks;78using AbsoluteXPath;79{80 {81 public void Open()82 {83 Console.WriteLine("Notepad is opened");84 }85 public void Close()86 {87 Console.WriteLine("Notepad is closed");88 }89 }90}91using System;92using System.Collections.Generic;93using System.Linq;94using System.Text;95using System.Threading.Tasks;

Full Screen

Full Screen

Notepad

Using AI Code Generation

copy

Full Screen

1using AbsoluteXPath;2{3 static void Main()4 {5 Notepad n = new Notepad();6 n.Run();7 }8}9using System;10using System.Windows.Forms;11{12 {13 public void Run()14 {15 Application.Run(new Form1());16 }17 }18}19using System;20using System.Windows.Forms;21{22 {23 public Form1()24 {25 InitializeComponent();26 }27 }28}29{30 {31 private System.ComponentModel.IContainer components = null;32 protected override void Dispose(bool disposing)33 {34 if (disposing && (components != null))35 {36 components.Dispose();37 }38 base.Dispose(disposing);39 }40 private void InitializeComponent()41 {42 this.SuspendLayout();43 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);44 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;45 this.ClientSize = new System.Drawing.Size(284, 261);46 this.Name = "Form1";47 this.Text = "Form1";48 this.ResumeLayout(false);49 }50 }51}

Full Screen

Full Screen

Notepad

Using AI Code Generation

copy

Full Screen

1using AbsoluteXPath;2{3 {4 public static void Main(string[] args)5 {6 Notepad n = new Notepad();7 n.OpenNotepad();8 }9 public void OpenNotepad()10 {11 System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();12 psi.FileName = "notepad.exe";13 System.Diagnostics.Process.Start(psi);14 }15 }16}17using AbsoluteXPath;18Notepad n = new Notepad();19n.OpenNotepad();20public void OpenNotepad()21{22System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();23psi.FileName = "notepad.exe";24System.Diagnostics.Process.Start(psi);25}

Full Screen

Full Screen

Notepad

Using AI Code Generation

copy

Full Screen

1using System;2using AbsoluteXPath;3{4 static void Main()5 {6 Notepad n = new Notepad();7 n.open();8 n.close();9 n.save();10 }11}

Full Screen

Full Screen

Notepad

Using AI Code Generation

copy

Full Screen

1using AbsoluteXPath;2using System;3{4 static void Main()5 {6 Notepad n = new Notepad();7 n.Create("C:\\Users\\Public\\Documents\\Notepad.txt");8 }9}

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run WinAppDriver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in Notepad

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful