question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to Initiate Session with WinAppDriver

See original GitHub issue

Description

I’m using WinAppDriver with a Java Framework. When I run the test the following log is displayed:

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 400. Message: Bad capabilities. Specify either app or appTopLevelWindow to create a session
Build info: version: '4.0.0', revision: '3a21814679'
System info: host: 'CHATHURANGA', ip: '192.168.8.148', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.12'
Driver info: io.appium.java_client.windows.WindowsDriver
Command: [null, newSession {capabilities=[{appium:app=C:\Windows\System32\notepad.exe, appium:automationName=Windows, appium:deviceName=WindowsPC, platformName=WINDOWS}], desiredCapabilities=Capabilities {app: C:\Windows\System32\notepad..., appium:automationName: Windows, deviceName: WindowsPC, platformName: WINDOWS}}]

Environment

  • Java version: 11
  • Appium Java Client version: 8.0.0-beta
  • Desktop OS/version: Windows 11
  • Selenium version: 4.0.0

Details

Following is the code used to initiate the session:

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName","Windows");
capabilities.setCapability("deviceName", "WindowsPC");
capabilities.setCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");
calculatorSession= new WindowsDriver(new URL("http://127.0.0.1:4723"), capabilities);
calculatorSession.manage().timeouts().implicitlyWait(Duration.ofSeconds(2));

But if I run the same code with the above capabilities using Appium Java Client v7.3.0 and Selenium 3.141 it works fine!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
KazuCocoacommented, Apr 26, 2022

The WinAppDriver requires selenium v3 based client for now since Selenium v4 requires W3C spec protocol that is not supported by WinAppDriver yet.

1reaction
mykola-mokhnachcommented, Nov 16, 2021

Also:

https://github.com/appium/java-client/blob/master/docs/v7-to-v8-migration-guide.md#strict-w3c-specification-compatibility

The recommended way to provide capabilities for driver creation is to use specific option builders inherited from BaseOptions class. For example XCUITestOptions to create a XCUITest driver instance or UiAutomator2Options to create an UiAutomator2 driver instance. If there is no driver-specific options class for your driver then either use BaseOptions builder as the base class to define your capabilities or request driver developers to add one. Do not use DesiredCapabilities class for this purpose in W3C context.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - WinAppDriver: org.openqa.selenium ... - Stack Overflow
WinAppDriver : org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session ... I am trying to automate tests in a desktop ...
Read more >
WinAppDriver:It is impossible to create a new session ...
WinAppDriver :It is impossible to create a new session because 'createSession' which takes HttpClient, InputStream and long was not found or it ...
Read more >
Issue on getting initialize notapad.exe using WinAppDriver
I'm trying to automate windows application like notepad, calculator using WinAppDriver in QAF and java bdd approach. My property file contains below properties....
Read more >
Unable to create a new remote session - Record Widows Action
Unable to create a new remote session. Please check the server log for more details. Original error: Failed to locate opened application ...
Read more >
WinApp driver with Python for desktop application automation
You must start WinAppDriver first to start the session and then run your code. 6. Once we reach the step of initiating the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found