Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not start a new session. Response code 400. Message: Bad capabilities. appium 8.3.0 #2089

Open
Luka7711 opened this issue Dec 29, 2023 · 6 comments

Comments

@Luka7711
Copy link

Luka7711 commented Dec 29, 2023

Description

Starting winapp driver session fails after we upgraded Selenium to 4.8.1 and appium to 8.3.0. I am trying to launch windows desktop application.
I followed documentation: appium migrate 7 -> 8

public void winAppInitialization() {
	if (winAppSession != null && winAppSession.getSessionId() != null) {
		return;
	}
	try {
		BaseOptions capabilities = new BaseOptions();
		capabilities.setCapability("app", appLocation);

		AppiumServiceBuilder serviceBuilder = new AppiumServiceBuilder();
		serviceBuilder.withCapabilities(capabilities).usingAnyFreePort().withTimeout(Duration.ofSeconds(10));
		AppiumDriverLocalService appiumDriverLocalService = AppiumDriverLocalService.buildService(serviceBuilder);

		appiumDriverLocalService.start();

		WindowsDriver driver = new WindowsDriver(new URL("http://localhost:" + appiumDriverLocalService.getUrl().getPort() + "/wd/hub"), capabilities);
		driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));

	} catch (Exception e) {
		throw new InitializationException("Error at initializing win app driver, win driver location: "
				+ winDriverURL + " and app location: " + appLocation);
	}
}

Error

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.8.1', revision: '8ebccac989' System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_391' Driver info: io.appium.java_client.windows.WindowsDriver Command: [null, newSession {capabilities=[{platformName=WINDOWS, appium:deviceName=WindowsPC, appium:automationName=Windows, appium:app=C:\Program Files (x86)\Trizetto\Facets\System\Bin\ceraexe0.exe}], desiredCapabilities=Capabilities {appium:app: C:\Program Files (x86)\Triz..., appium:automationName: Windows, appium:deviceName: WindowsPC, platformName: WINDOWS}}] Capabilities {appium:app: C:\Program Files (x86)\Triz..., appium:automationName: Windows, appium:deviceName: WindowsPC, platformName: WINDOWS}

@mykola-mokhnach
Copy link
Contributor

mykola-mokhnach commented Dec 30, 2023

Please provide the full Appium server log

@Luka7711
Copy link
Author

Luka7711 commented Dec 30, 2023

@mykola-mokhnach I've updated Initilaization class where I start appium server first and then starting winapp driver. Here's logs:

io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException: The local appium server has not been started. The given Node.js executable: C:\Program Files\nodejs\node.exe Arguments: [C:\Users\0029031\AppData\Roaming\npm\node_modules\appium\build\lib\main.js, --port, 8490, --address, 0.0.0.0, --default-capabilities, {"appium:app":"C:\Program Files (x86)\Trizetto\Facets\System\Bin\ceraexe0.exe"}]
Process output: usage: main.js server [-h] [--address ADDRESS] [--allow-cors]
[--allow-insecure ALLOW_INSECURE]
[--base-path BASE_PATH]
[--callback-address CALLBACK_ADDRESS]
[--callback-port CALLBACK_PORT] [--debug-log-spacing]
[--default-capabilities DEFAULT_CAPABILITIES]
[--deny-insecure DENY_INSECURE]
[--keep-alive-timeout KEEP_ALIVE_TIMEOUT]
[--local-timezone] [--log LOG]
[--log-filters LOG_FILTERS] [--log-level LOG_LEVEL]
[--log-no-colors] [--log-timestamp]
[--plugins-import-chunk-size PLUGINS_IMPORT_CHUNK_SIZE]
[--drivers-import-chunk-size DRIVERS_IMPORT_CHUNK_SIZE]
[--long-stacktrace] [--no-perms-check]
[--nodeconfig NODECONFIG] [--port PORT]
[--relaxed-security] [--session-override]
[--strict-caps] [--tmp TMP] [--trace-dir TRACE_DIR]
[--use-drivers USE_DRIVERS] [--use-plugins USE_PLUGINS]
[--webhook WEBHOOK] [--ssl-cert-path SSL_CERT_PATH]
[--ssl-key-path SSL_KEY_PATH] [--shell]
[--show-build-info] [--show-config]
[--config CONFIGFILE]

main.js server: error: argument --default-capabilities/-dc: invalid json value: '{appium:app:C:\\Program'

@mykola-mokhnach
Copy link
Contributor

Unfortunately I cannot help without the full server log

@Luka7711
Copy link
Author

Luka7711 commented Jan 3, 2024

How about this, it's not helpful either?

io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException: The local appium server has not been started. The given Node.js executable: C:\Program Files\nodejs\node.exe Arguments: [C:\Users\0029031\AppData\Roaming\npm\node_modules\appium\build\lib\main.js, --port, 8490, --address, 0.0.0.0, --default-capabilities, {"appium:app":"C:\Program Files (x86)\Trizetto\Facets\System\Bin\ceraexe0.exe"}]
Process output: usage: main.js server [-h] [--address ADDRESS] [--allow-cors]
[--allow-insecure ALLOW_INSECURE]
[--base-path BASE_PATH]
[--callback-address CALLBACK_ADDRESS]
[--callback-port CALLBACK_PORT] [--debug-log-spacing]
[--default-capabilities DEFAULT_CAPABILITIES]
[--deny-insecure DENY_INSECURE]
[--keep-alive-timeout KEEP_ALIVE_TIMEOUT]
[--local-timezone] [--log LOG]
[--log-filters LOG_FILTERS] [--log-level LOG_LEVEL]
[--log-no-colors] [--log-timestamp]
[--plugins-import-chunk-size PLUGINS_IMPORT_CHUNK_SIZE]
[--drivers-import-chunk-size DRIVERS_IMPORT_CHUNK_SIZE]
[--long-stacktrace] [--no-perms-check]
[--nodeconfig NODECONFIG] [--port PORT]
[--relaxed-security] [--session-override]
[--strict-caps] [--tmp TMP] [--trace-dir TRACE_DIR]
[--use-drivers USE_DRIVERS] [--use-plugins USE_PLUGINS]
[--webhook WEBHOOK] [--ssl-cert-path SSL_CERT_PATH]
[--ssl-key-path SSL_KEY_PATH] [--shell]
[--show-build-info] [--show-config]
[--config CONFIGFILE]

main.js server: error: argument --default-capabilities/-dc: invalid json value: '{appium:app:C:\Program'

@mykola-mokhnach
Copy link
Contributor

This looks like an error from an older client version. Consider using the most recent one as we don't backport fixes to older releases.

@lucasandre22
Copy link

Hey @Luka7711, what is the value of the appLocation String?
It looks like the value may be C:\Program Files\... and Java is trying to parse it after the first space (it is not necessary to scape spaces).
Try to use DesiredCapabilities instead of BaseOptions in your code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants