Home>

I'm considering whether Appium can automate the work, but it's not working well due to lack of knowledge.
I tried to create a simple program to open notepad, type letters, and save
FindElementByName ("File name:"). SendKeys ("test.txt") does not reflect test.txt"in the text box.
Can you tell me how to operate correctly?

using OpenQA.Selenium.Remote;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AppiumTest01
{
    class Program public static void Main (string [] args)
      {
            var drivers = new Dictionary<string, RemoteWebDriver>();
            // Execute Windows Application Driver
            string serverPath = System.IO.Path.Combine (
              "C: \\ work", @ "Windows Application Driver", "WinAppDriver.exe"
            );
            System.Diagnostics.Process.Start (serverPath);
            DesiredCapabilities appCapabilities = new DesiredCapabilities ();

            //Notepad
            appCapabilities.SetCapability ("app", @ "C: \ Windows \ System32 \ notepad.exe");
            drivers.Add ("notepad", new RemoteWebDriver (new Uri (@ "http://127.0.0.1:4723"), appCapabilities));

            drivers ["notepad"]. Manage (). Timeouts (). ImplicitlyWait (TimeSpan.FromSeconds (2));
            //drivers["notepad"].FindElementByClassName("Notepad").SendKeys("Hello Windows Application Driver World! ");
            drivers ["notepad"]. FindElementByName ("Text Editor"). SendKeys ("Hello Windows Application Driver World!");
            drivers ["notepad"]. FindElementByName ("File (F)"). Click ();
            drivers ["notepad"]. FindElementByName ("Save As ..."). Click ();// So far it works
            drivers ["notepad"]. FindElementByName ("File name:"). SendKeys ("test.txt");//  Here

            drivers ["notepad"]. Dispose ();
            drivers ["notepad"] = null;
     }