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

Created on 30 Jan 2018  路  14Comments  路  Source: appium/java-client

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 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)
bug

Most helpful comment

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/, 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?

All 14 comments

I am having very similar issue when using java client versions above 4.1.2. I allow gradle to handle Selenium dependancy version so I'm assuming Selenum client version is OK. Connecting to a remote server - Appium - 1.7 and Selenum 3.4. Error occurs in HasSessionDetails - getSessionDetail("platformName") which is called from AppiumDriver. I verified the platformName has a value during runtime.

Guys, any suggestions please?

I have the same behavior , it due to AppiumCommandExecutor which does not work very well
(I tried to set up a proxy like suggested here : http://developers.perfectomobile.com/pages/viewpage.action?pageId=21430723)

any suggestions please ? :(

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/, 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?

@saikrishna321 : I was talking about this issue!

@saikrishna321 Hello! Did you get a chance to look into this?

@abhivaikar sorry mate was busy with work. Will look into this sooner

I can able to reproduce it @thaitrongnghi @abhivaikar Will fix it soon.

Great, we are looking forward to the fix. Thanks @SrinivasanTarget in advance.

@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);

It now works for me with your great suggestion @Invictum, thank you a lot ;)

@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);

Could you provide more details about your imports ?
How did you instantiate the clientFactory ?
Did you use the executor before your capabilities ?
I will appreciate a reply.
I'm working with 6.0.0-BETA2 Appium-client.

It now works for me with your great suggestion @Invictum, thank you a lot ;)
Could you provide more details about your imports ?
How did you instantiate the clientFactory ?
Did you use the executor before your capabilities ?
I will appreciate a reply.
I'm working with 6.0.0-BETA2 Appium-client.

Was this page helpful?
0 / 5 - 0 ratings