I am running some test on real Android device. I installed APpium server via pm. I can run Appium server with Windows command line 'appium'.
I try to start the appium server from my python code with these lines of code:
appium_service = AppiumService()
appium_service.start()
but nothing happened! I don't get any output, no error message, no exception, nothing.
So I tried again by passing some parameters:
appium_service = AppiumService()
appium_service.start(address='0.0.0.0', p='4723')
Again nothing happened!
It seems the code is waiting... or sleeping.... these lines of code are at the beginning of the script... I can see some logger messages for the initialization of my webdriver... but then nothing.
Is there anyone please who can help me to debug and to make run APpium server from my code without the command line os option.
First of all its good to check manually if "appium" command on shell launches the appium server or not(Seems in your case its working fine). In my case it was not with the installation of Appium desktop version. Posting the details of what i did to resolve this in case it helps someone:
Installed npm (as part of node installation, MSI available at nodejs.org)
npm install -g appium
Now to answer your main question, below is what i used in my Python script to start the appium server on a new window so that it runs separately from the rest of the script execution:
import os
os.system("start /B start cmd.exe #cmd /k appium")
In case you want to change the port(e.g. to 4728) of the appium server (may be when you have multiple servers for multiple devices) you can use following:
os.system("start /B start cmd.exe #cmd /k appium -a 127.0.0.1 -p 4728")
Related
I want to ping certain IPs in a project, and I am using npm ping package for this.
https://www.npmjs.com/package/ping
When I run the service, its running fine. But when is run my service in the PM2, the command prompt windows are showing up, each time the ping action is done in that service(I am pinging in loops to monitor an IP).
What is the reason for this and please suggest an alternative solution.
The same problem happened to me while using forever to run my script in background.
I've found that using START /B node script.js on windows instead of forever worked just fine and the command prompt didn't showed up. I don't know much about PM2 but maybe you should be able to prefix your command with START /B somewhere in PM2 or just run your script by yourself.
I am trying to understand how to display the logs of Appium server for my python code.
First of all, I educated myself more about python logs And I made some experiments with 3 ways to sart Appium server before to come to you.
1)I tried by this way:
appium_service = AppiumService()
appium_service.start()
But I don't see any log. I guess I need to modify the python file of appium_service method.
2) So I tried to start appium server with command (I added the flag of scurity you suggested):
os.system("start /B start cmd.exe #cmd /k appium --relaxed-security --log-timestamp --log appium.log -a 127.0.0.1 -p 4728")
I could see some logs in terminal but not so much than Appium GUI server.
3) To show you the difference, I commented the lines of code which start Appium server, and I start it by hand with Appium GUI.
As you can see Appium GUI logs give more information to debug my code.
What should I do to display same info in Appium terminal than Appium GUI?
What should I do to display same info in 'appium_service.start()' than Appium GUI?
I am working since 3 days to understand how can I show these logs without Appium GUI as my code need to run without any human interaction.
Thanks for your help.
I got a task to create a powershell or a batch file on Windows which should, in sequence, start a "node file.js", then call a "npm start" command in another directory and then launch a browser to localhost:3000.
The problem is that I can not get the exact time when to launch the browser at the very end. I tried to concatenate commands with & and && (How to run two commands in one line in Windows CMD?) but the browser got launched before the scripts reach the end in the first case, never in the second case. I guess cmd simply can't understand when node or npm commands are finished to be executed.
Does anybody have experience with this particular task?
I installed forever and forever-win globally using npm and started my app.js using 'forever start app.js' and this works but it opens a 'nodejs window' which I cannot close.
Is there a way in windows to start my application from commandline using forever without this nodejs window appearing?
Start it as a background process from command line.
START /B program
See this superuser question for more details.
Does anyone know how you would run the following command within TeamCity? (the command is normally ran in a Node.js command window)..."Karma start karma.conf.js". I have successfully installed Nodejs on the TeamCity server. I have then successfully installed Karma on the same server (using npm install -g karma).
In TeamCity, my build step has "Runner type = Command Line", and the Custom Script is set to "FULLPATHOFKARMAEXE\karma.cmd start FULLPATHOFKARMACONFIGFILE/kara.conf.js"
When i run TeamCity, it comes back with the error "node is not recognized as an internal or external command"
Anyone know the step-by step process of running Karma within TeamCity?
In your case, the Karma installation seems to be OK, but your TeamCity agent process is unable to resolve the path to Node.exe (it's installation folder is missing from the %PATH% variable).
First verify the NodeJS installation by opening a Commandline window on the agent machine, type node and press enter:
c:> node
>
If the result in your Command window is a >-prompt, you might solve your problems by restarting the build agent.
If the result in your Command window is some error message saying "node is not recognized as an internal or external command", you need to add the NodeJS installation folder to the %PATH% variable, and restart the build agent.
You can, of course, just change the %PATH% for your build agent service by running a initialization script included in the NodeJS installtion folder in your build step. Depending on where your NodeJS installastion is, your custom script might look like this:
"C:\Program Files (x86)\nodejs\nodevars.bat"
"FULLPATHOFKARMAEXE\karma.cmd start FULLPATHOFKARMACONFIGFILE/kara.conf.js"