WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

Win app driver not working in Selenium Webdriver Typescript

Open laksman2003 opened this issue 1 year ago • 11 comments

Trying to use Win App Driver with Typescript to automate a Windows Desktop App. And when I run the below code in any test framework I get a 400 error in win app driver and I see a error message browser is mandatory eventhough am testing a desktop app.

And when I give a some value for browserName it still gives 400 error in win app driver with error message either app or appLevelTopWindow should be given

app is Root so I can iterate through all available apps. The same approach works with C# Webdriver and with C# as coding language but not working with Typescript with Selenium Webdriver and Selenium Appium

const capabilities = {
  platformName: 'Windows',
  deviceName: 'WindowsPC',
  app: 'Root' 
};

await driver.startWithCapabilities(capabilities);

Below are libraries used in node js Selenium-webdriver: 4.18.1 Selenium-appium: 4.1.22

laksman2003 avatar Mar 26 '24 22:03 laksman2003

Selenium 4 will not work, you need to downgrade to selenium 3

anunay1 avatar Mar 27 '24 12:03 anunay1

Its is working after downgrading to Selenium "selenium-webdriver": "3.6.0" and "selenium-appium": "1.0.2" But its very slow in finding new windows which appear in app. But while using .net C# it is very fast in finding the same windows with same selectors.

Is there a reason why Windows App Driver is quite slow (over 2 minutes) in finding new windows with Typescript but faster with C# .net Webdriver? C# .Net webdriver version am using is Selenium.WebDriver - 3.141.0 and Appium.WebDriver - 4.4.5

laksman2003 avatar Apr 02 '24 01:04 laksman2003

@anunay1 Is Selenium 4 totally out of support? I am writing a Python script to automate a Win app that uses MS WebView2, and i want to automate that webview using Selenium 4's Attach to Session feature, similar to this issue

Edit: It seems like there are users using Selenium 4 https://github.com/microsoft/WinAppDriver/issues/1668

MagdelineNg avatar Apr 08 '24 15:04 MagdelineNg

Yes it is unfortunately.

anunay1 avatar Apr 08 '24 15:04 anunay1

And python language binding has other issues like action classes does not work properly. You might face issues like right click and all.

anunay1 avatar Apr 08 '24 16:04 anunay1

@anunay1 Yep, I realised problems in locating elements using the Selenium webdrivers when I upgrade to Selenium 4. For example,

    time_and_language_menu_bar = settings_driver.find_element_by_xpath(config_file["xpaths"]["TimeAndLanguageMenuBar"])   
    print("time_and_language_menu_bar: ", time_and_language_menu_bar)  #returns a dictionary instead of the WebElement
    time_and_language_menu_bar.click()  #error

Are there any ways to automate the WebView2 using Selenium 3, as I understand WinAppDriver is not able to automate WebViews? Or are there any ways to overcome these issues with Selenium 4?

MagdelineNg avatar Apr 08 '24 16:04 MagdelineNg

I don't know what your compulsion is with python is? Is it your project call? But moving to C# will be a good option. And follow the link in the ticket you have mentioned above.

anunay1 avatar Apr 08 '24 16:04 anunay1

@anunay1 hi, my project is able to switch to C#, but I would still have to use selenium 3 as winappdriver does not support selenium 4. Will automating Microsoft webview be a problem with selenium 3 (I am referring to this link https://learn.microsoft.com/en-us/microsoft-edge/webview2/how-to/webdriver#attaching-microsoft-edge-webdriver-to-the-launched-webview2-app)

MagdelineNg avatar Apr 19 '24 13:04 MagdelineNg

I don't think so. As long as you are on selenium 3.

anunay1 avatar Apr 19 '24 17:04 anunay1

@anunay1 Hi, Selenium 3 does not actually support webview2 according to https://github.com/MicrosoftEdge/WebView2Feedback/discussions/3892#discussioncomment-7244130 . Will WinAppDriver work with Selenium 4 in C# Nunit?

MagdelineNg avatar Apr 20 '24 13:04 MagdelineNg

I don't know I have not tried.

anunay1 avatar Apr 20 '24 14:04 anunay1