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.
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
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.
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 -
For Android SYSTEM_PORT
caps.setCapability(AndroidMobileCapabilityType.SYSTEM_PORT, <unique port>);
For iOS SYSTEM_PORT
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.