I came across many situation where people want to start the application directly using WinAppDriver.
Sometimes, they come across many weird error and are stuck waiting for someone to resolve.
One of the alternative to this problem is to create a session of Windows Desktop and then finding the right Windows in your desktop session. This code is my personal favorite.
Code below
RemoteWebDriver WindowsDesktopSession;
DesiredCapabilities WindowsDesktopCapabilities;
IWebElement TargetWindow;
WindowsDesktopCapabilities = new DesiredCapabilities();
WindowsDesktopCapabilities.SetCapability("app", "Root");
WindowsDesktopCapabilities.SetCapability("deviceName", "WindowsPC");
WindowsDesktopSession= new RemoteWebDriver(new Uri("http://127.0.0.1:4723"), WindowsDesktopCapabilities);
TargetWindow = WindowsDesktopSession.FindElement(By.XPath( strTargetAppicationWindowsXPath));
There you go!
Now you have the "TargetWindow", start using this object to explore the elements present inside this Window.
-Pankaj Dhapola
Let's Think on it
No comments:
Post a Comment