0

I want to automate a SQL developer tool so I'm trying to click on the "create new connection" button create new connection using relative XPath. Why is WinAppDriver failing to click on the button?

Output-Error

using System;
using SikuliSharp;
using System.Diagnostics;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Windows;
using System.Threading;
namespace A_SQL_SP
{
    internal class Program
    {
        private static WindowsDriver<WindowsElement> windriver = null; //Global variable 
        static void Main(string[] args)
        {
            //Appium.WebDriver OR WinappDriver Code Start here
            Process.Start(@"C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe");//Starting WinAppDriver.exe\\C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe
            AppiumOptions op = new AppiumOptions();//creating object/instance of appium note:this is not actual appium this is c# appium which is different than real one.                               
            op.AddAdditionalCapability("app", @"C:\Program Files (x86)\sqldeveloper\sqldeveloper.exe"); //defining which application we want to automate
            op.AddAdditionalCapability("deviceName", "WindowsPC");//Adding platform like windows,macos,android,ios etc
            op.AddAdditionalCapability("appArguments", "-internal -NoSplash");//skiping flash screen
            try  //Some time windows application take time to get start/open so to avoid error we used try and catch block here 
            {
                var windriver = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), op); // Accessing WinAppDriver control into variable: driver
                windriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30); //30 sec //don't use Thread.Sleep(2000);//2 sec as it increase RAM load
                windriver.SwitchTo().Window(windriver.WindowHandles[0]);
                windriver.Manage().Window.Maximize();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Turn On Windows developer mode for 'Appium.WebDriver OR WinappDriver Code only i.e Sikuli won't require Windows developer mode=ON' follow  Steps:Setting->Update & Security->For Developers->Developer Mode,Message from Sharad_P");
                Console.WriteLine("---------------------------------------------------------------------------------------------------------------------");
                Console.WriteLine(ex.ToString());
            }
            WindowsElement newcon = windriver.FindElementByXPath("//Button[@Name='New Connection']");
            newcon.Click();
            windriver.Close();//Close windriver process
            windriver.Quit();//Stop windriver process out and out 
        }
    }
}
JeffC
  • 22,180
  • 5
  • 32
  • 55
Sharad
  • 9
  • 5
  • 2
    Screenshots of the UI are great, screenshots of code or HTML are not. Please read why [a screenshot of code/HTML is a bad idea](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors). – JeffC Apr 30 '23 at 14:21
  • 1
    Pull the driver instantiation out of the `try` and then you'll see what the actual error is. It's not getting instantiated. – JeffC Apr 30 '23 at 14:22

0 Answers0