ajpilu
August 15, 2022, 3:27pm
1
Hello,
I have a framework using Wdio, node.js and Appium.
I want to stop and start the appium server before each test so I want to add the logic in the beforeSession hook.
I’ve tried executing CLI commands using child_process but it does not start / stop the server.
The same commands are working ok if I am inputting them manually in the MacOS terminal.
However if I am executing ls it works.
Can someone help on how to achieve this?
Thanks!
wreed
August 15, 2022, 11:12pm
2
Here is a tutorial on starting Appium server programmatically in Java using AppiumServiceBuilder. There are code examples on how to start in @Before Method and how to clean up with @After :
https://www.headspin.io/blog/starting-an-appium-server-programmatically-using-appiumservicebuilder
ajpilu
August 16, 2022, 5:37am
3
@wreed I am using JS not Java so I don’t know exactly how the tutorial can help me. I didn’t found anything on JS out there.
I’ve tried that small portion with Appium.main but doest not work.
wreed
August 16, 2022, 4:05pm
4
Sorry, I guess that’s what I get for trying to be a mind reader
Here is a tutorial on Appium using Javascript that starts the server programmatically:
https://digital.ai/catalyst-blog/follow-this-guide-to-set-up-appium-automation-using-javascript
ajpilu
August 16, 2022, 8:55pm
5
@wreed I’ve tried this approach with builder but without any success.
It throws: TypeError: Target browser must be a string but is ; did you forget to call forBrowser()?
wreed
August 16, 2022, 9:47pm
6