microsoft / WinAppDriver

Windows Application Driver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WinAppDriver, Code 400 error: could not start a new session

Twindgor opened this issue · comments

Hi, i keep getting the following error, even though the simple automation script that tests Windows calculator, seems fine. Thw WinAppDriver server is up and listening to the localhost, developer mode is on, maven dependencies (Selenium v 4.16 & Appium java client v 9.00).
The full error:
" Exception in thread "main" 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
Host info: host: 'DESKTOP-B0V0U3V', ip: '10.100.102.13'
Build info: version: '4.16.1', revision: '9b4c83354e'
System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.4.1'
Driver info: io.appium.java_client.windows.WindowsDriver
Command: [null, newSession {capabilities=[{appium:app=C:\Windows\System32\calc, appium:appTopLevelWindow=Calculator, appium:automationName=Windows, appium:deviceName=WindowsPC, platformName=windows}], desiredCapabilities=Capabilities {app: C:\Windows\System32\calc, appTopLevelWindow: Calculator, appium:automationName: Windows, deviceName: WindowsPC, platformName: windows}}]
Capabilities {app: C:\Windows\System32\calc, appTopLevelWindow: Calculator, appium:automationName: Windows, deviceName: WindowsPC, platformName: windows}
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:140)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:133)
at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:102)
at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:177)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:238)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:523)
at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:268)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:164)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:90)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:102)
at io.appium.java_client.windows.WindowsDriver.(WindowsDriver.java:50)
at com.WinApp.WinAppTest2.main(WinAppTest2.ja
And the code:
"package com.WinApp;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;

import io.appium.java_client.windows.WindowsDriver;

public class WinAppTest2 {

public static WindowsDriver driver = null;

public static void main(String[] args) {

	DesiredCapabilities cap = new DesiredCapabilities();
	cap.setCapability("app","C:\\Windows\\System32\\calc.exe");
	cap.setCapability("platformName", "Windows");
	cap.setCapability("deviceName", "WindowsPC");
	try {
		driver = new WindowsDriver(new URL("http://127.0.0.1:4723"), cap);
	} catch (MalformedURLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();

	}
	

	
}

}
Please help, i'm desperate already.

Hi @Twindgor, I think you are using win app driver 1.2.99 which is latest but it is not supported by appium to use due to w3 standards, either move to win app driver 1.2.1 or you have to run win app separately without Appium.

hi @RakeshDangi-slt, first thank you for replying ti my issue. i think WAD 1.2.1 didn't work as well if i recall right, but you mentioned Appium usage, should i actually install the Appium tool to use it with WAD? because all i did was to place its maven dependency appium java-client in my pom.xml and that's it, maybe this could be the issue?
and another thing, if i want i could work with WAD without Appium? how can i do it? is there a substitutive way?
thanks.

@Twindgor If you want to use appium then you have to install node then npm on your pc and then appium and windows automation driver, and then launch appium at specific URL and port and then when you make call to that URL it will send the request to win app driver and will work fine.
If you want to use the WAD separately you cannot use selenium functions it will give errors due to selenium version miss match and you will face a lot of issues.
Tell me what you want to achieve with this automation?

@RakeshDangi-slt I want to simply practice automation testing at home using a simple automation tool. I will try what you said with Appium. anyway, do you think SikuliX is easier to use instead? like, i could just add SkiliX's API jar in my Eclipse classpath and if you think it should work i won't even need the WAD as i found an alternative tool. Please tell me if u r familiar with SikuliX and thinks it's worth a shot.

SikuliX is just an image automation framework it is not as good as selenium and you can only verify things based on images, most people dont prefer this.
If you want to test any tool I have all these already added to my tool, https://soliterata.com/ you can use this for automation.