1

Can I start 2 appium server instances on my machine at the same time so that I can execute my test script simultaneously on 2 different devices connected to the machine? Actually what I'm trying is to run my test script on 2 devices connected to same windows machine. For this I am using TestNG to pass the Android Driver url to start session. This url will be dynamic as 2 devices will be using 2 Appium server instances. Can I create 2 instances of Appium server at same time? If so then can I use code to create those instances as I don't want to use GUI to start it.

Amrit
  • 89
  • 1
  • 4
  • 11
  • Possible duplicate of [How to start the Appium server from command prompt in MAC machine?](http://stackoverflow.com/questions/25659168/how-to-start-the-appium-server-from-command-prompt-in-mac-machine) – JaysonP Oct 21 '16 at 19:13

1 Answers1

1

This question has already been asked and answer (if I am reading what you want correctly).

Please refer to How to start the Appium server from command prompt in MAC machine?

On a windows machine there should be an appium executable which you run with the command line arguments --address 127.0.0.1 -p 4273

In essence all you need to do is use a different port for your tests.

Community
  • 1
  • 1
JaysonP
  • 164
  • 1
  • 10
  • Actually what I'm trying is to run my test script on 2 devices connected to same windows machine. For this I am using TestNG to pass the Android Driver url to start session. This url will be dynamic as 2 devices will be using 2 Appium server instances. Can I create 2 instances of Appium server at same time? If so then can I use code to create those instances as I don't want to use GUI to start it. – Amrit Oct 22 '16 at 04:14
  • You can do that by running appium from command line. All you need to do is specify a different port number when running ie `-p 4723` and `-p 4823` from this you just need to specify what port is being used for each driver instance in your TestNG scripts. That is instead of a hardcoded value for the port you will need to set a variable for the port value: `http://127.0.0.1:/wd/hub` – JaysonP Oct 24 '16 at 13:04
  • Did this work? If not if you were to install using `npm` and appium is on your path, you can run via: `appium --address 127.0.0.1 -p 4273` – JaysonP Oct 26 '16 at 17:31
  • This appium --address 127.0.0.1 -p 4273 command is only launching the appium.exe file. Unable to click on start server button. Can you please let me know what might be the issue? – Amrit Nov 08 '16 at 13:46
  • Try running using `node` ie `node . --address 127.0.0.1 -p 4723` – JaysonP Nov 08 '16 at 13:58
  • Got another solution where I navigated to C:\Program Files\Appium\node_modules and in command prompt I typed node appium and it worked. – Amrit Nov 08 '16 at 14:05
  • That would also work, depending on how your node_modules are setup you may need to be in a specific folder for it to work. – JaysonP Nov 08 '16 at 14:07
  • Hey @JaysonP its working but once a server is running I am unable to start another new one. Do I need to open it in a new command prompt. – Amrit Nov 08 '16 at 14:11
  • Can I incorporate some code in Java to automate this process i.e. opening cmd and giving this command or if we could create a batch file and trigger it from our test case itself? – Amrit Nov 08 '16 at 14:20
  • You could do that, or you could look into using Selenium grid. There is a bunch of documentation online for it. – JaysonP Nov 08 '16 at 14:48
  • So now that you have one working you need to run a new command prompt using a different port ie `-p 4733` – JaysonP Nov 08 '16 at 14:49
  • ProcessBuilder pb = new ProcessBuilder("cmd.exe","node","appium"); pb.directory((new File("C:\\Program Files\\Appium\\node_modules"))); pb.start(); System.out.print("Appium Server Started"); It shows CreateProcess Error 740 @JaysonP need little help to fix this issue. – Amrit Nov 09 '16 at 13:36
  • I am unsure of how you are trying to open the server – JaysonP Nov 09 '16 at 15:35
  • I am trying to write a Java code where I want to open cmd prompt, then change the working directory and finally fire the command node appium so that my appium server starts. For this I was trying with the above code but its not working. I am trying to do end to end automation. – Amrit Nov 10 '16 at 03:25
  • I would reference another question for this such as http://stackoverflow.com/questions/8496494/running-command-line-in-java as it more pertains to a java coding question instead of your original appium question – JaysonP Nov 10 '16 at 14:15
  • Finally it worked. I used Runtime.getRuntime() command to start cmd and change directory. After that I started a batch file containing node appium command. It worked for me. Thanks @JaysonP. – Amrit Nov 15 '16 at 04:08
  • Perfect! Great to hear you have it working. Please mark this as answered for anyone else searching to solve this problem. – JaysonP Nov 15 '16 at 06:59