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?
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
}
}
}