Can we use multiple session in same appium port?

I want to test two android devices but I want to use same appium port. Can I use same port with two different sessions?

No you cannot use multiple sessions on a single port for appium.

You have to start appium server at 2 different ports and use those server url in u r script to create multiple sessions or you can use grid.

@robinvivacius

In v1.7.0 (https://github.com/appium/appium/releases/tag/v1.7.0) they added:

Support multiple simultaneous sessions in Android and iOS (9+)

I never tested tho. Investigate and place your findings in this forum :slight_smile:

1 Like

@Telmo_Cardoso

By multiple session do you mean starting Appium Server on multiple ports ? If yes then this was supported in 1.6 also. If no is there any sample code to achieve that.

@Venkatesh probably its that :slight_smile: Like I told I never tested, so I’m not sure how it works, was just letting @robinvivacius know of the possibility of using one Appium server to handle multiple sessions.

@Telmo_Cardoso OK, Thanks.

@Telmo_Cardoso thanks for this info. I’ll look in this feature

But question was can we use multiple appium session on single port so answer for that still hold NO. Thanks

Yes, you can have multiple session on a single Appium server v1.7.0+ (e.g. single Appium server running on port 4723, controlling multiple device/sim, both platform droid and iOS)
You need to add additional caps as below -

  1. For Android SYSTEM_PORT
    e.g. caps.setCapability(AndroidMobileCapabilityType.SYSTEM_PORT, <unique port>);

  2. For iOS SYSTEM_PORT
    e.g. caps.setCapability(IOSMobileCapabilityType.WDA_LOCAL_PORT, <unique port>);

P.S. Tried and tested, Make sure to use a fresh instance of the Appium server on every cycle of execution.

2 Likes

System port doesn’t work for me, can anyone have sample code?