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.

UnsupportedCommandException: getSession error occurs when setting timeout for appium android webdriver

See original GitHub issue

Description

I want to custom HTTP timeout when connecting to Appium server but it is always failed. Please see script to reproduce in “My script” section. Appreciate any suggestions, thank you a lot!

Environment

OS: macOS Sierra appium-java-client: 6.0.0-BETA2 Selenium version: 3.4.0 Others: IntelliJ, Java 1.8.0_121-b13

My script

DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(“deviceOrientation”, “portrait”); capabilities.setCapability(“app”, “/Users/local/Downloads/appTest.apk”); capabilities.setCapability(“platformName”,“Android”); capabilities.setCapability(“deviceName”, “HTC”);

int con_timeout = 1200000; int soc_timeout = 90000; ApacheHttpClient.Factory clientFactory = new ApacheHttpClient.Factory(new HttpClientFactory(con_timeout, soc_timeout)); AppiumCommandExecutor executor = new AppiumCommandExecutor(new HashMap<String, AppiumCommandInfo>(), new URL(“http://localhost:4723/wd/hub”), clientFactory); driver = new AndroidDriver<>(executor, capabilities); driver.launchApp(); sleep(200);

Error log from client side

It gives an error at step “driver = new AndroidDriver<>(executor, capabilities);” in my below script. org.openqa.selenium.UnsupportedCommandException: getSession Build info: version: ‘3.4.0’, revision: ‘unknown’, time: ‘unknown’ System info: host: ‘localhost’, ip: ‘*’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.12’, java.version: ‘1.8.0_121’ Driver info: driver.version: AndroidDriver

at org.openqa.selenium.remote.http.AbstractHttpCommandCodec.encode(AbstractHttpCommandCodec.java:220)
at org.openqa.selenium.remote.http.AbstractHttpCommandCodec.encode(AbstractHttpCommandCodec.java:118)
at io.appium.java_client.remote.AppiumCommandExecutor.doExecute(AppiumCommandExecutor.java:130)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:162)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:46)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at io.appium.java_client.HasSessionDetails.getSessionDetails(HasSessionDetails.java:36)
at io.appium.java_client.HasSessionDetails.getSessionDetail(HasSessionDetails.java:42)
at io.appium.java_client.HasSessionDetails.getPlatformName(HasSessionDetails.java:46)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:100)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:523)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:224)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:146)
at org.testng.TestRunner.beforeRun(TestRunner.java:626)
at org.testng.TestRunner.run(TestRunner.java:594)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:127)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
abhivaikarcommented, Jun 14, 2018

I am facing a similar issue for AndroidDriver. No issues observed for iOS.

I get UnsupportedCommandExecution when I call new AppiumFieldDecorator(driver) inside a PageObject constructor. When I debugged in, I see that AppiumFieldDecorator tries to invoke HasSessionDetails.getSession("platformName") which in turn tries to execute a GET /session and fails.

This is screenshot of debugging code where I see the response after executing GET /session is SessionID: null, Status: 9, Value: null image 5

Also when I debugged actual response from ApacheHttpClient for GET http://127.0.0.1:4723/wd/hub/session/<sessionId>, it is 404 Not Found. image

Environment

OS: macOS High Sierra Appium Server: 1.7.2 appium-java-client: 6.0.0-BETA4 Selenium version: 3.9.0 Others: IntelliJ, Java 1.8.0_161

This issue has completely blocked me from executing tests for Android. Can someone please take a look??

@ryltar , @thaitrongnghi , @cdj0924 has anything worked for you?

@SrinivasanTarget , @saikrishna321 Could you please help take a look?

2reactions
Invictumcommented, Sep 6, 2018

@thaitrongnghi @SrinivasanTarget @saikrishna321 @ryltar To resolve issue additional Appium commands should be supplied. This commands are available in io.appium.java_client.MobileCommand.commandRepository repository.

So executor should be constructed something like this

AppiumCommandExecutor executor = new AppiumCommandExecutor(MobileCommand.commandRepository, new URL("http://localhost:4723/wd/hub"), clientFactory);
Read more comments on GitHub >

github_iconTop Results From Across the Web

UnsupportedCommandException: getSession error occurs when ...
UnsupportedCommandException : getSession error occurs when setting timeout for appium android webdriver.
Read more >
Timeouts - Appium
The type of operation to set the timeout for. Valid values are: 'script' for script timeouts, 'implicit' for modifying the implicit wait timeout...
Read more >
org.openqa.selenium.UnsupportedCommandException
UnsupportedCommandException : An unknown command error occurred while executing commands ... Command duration or timeout: 318 milliseconds
Read more >
org.openqa.selenium.UnsupportedCommandException error ...
I have updated my appium to 1.5.3 and fixed your issue & it will help ... the returns are different in comparison between...
Read more >
Troubleshooting Error Message: Failed to execute command ...
you are using the setExecutionIdCapability method – it allows the driver to connect to the device that is currently open in the Cloud/IDE....
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