Appium server sometimes it does not stop when you try to close it, server and port is still hanging forever and the Appium CLI has no build-in command to stop the server which makes it harder to manage programmatically
Imagine that you want to manage it programmatically with the automation process in your CI/CD pipeline
such as Jenkins it could be a really painful story
appium
or
appium & (as background process)
The command to start Appium server that can be stopped only when you terminate it but sometimes it not stop
I've searched for the answer on StackOverflow for a long time and none of them answer directly to my question
So far what seems to work is that you have to kill the process of the server manually in the shell with the specific process id
To make it simply work with the pipeline, we could have a short version of the command
kill $(lsof -t -i :4723)
kill \$(lsof -t -i :${APPIUM_PORT}) [In Jenkinsfile]
Where the APPIUM_PORT is your Appium port, the default port is 4723
lsof command should work in Unix-like systems e.g. MacOS, Linux
lsof is a command meaning "list open files", which is used in many
Unix-like systems to report a list of all open files and the processes
that opened them
By running this command it should return an ID of the process running on that specific port to use for the kill signal
To implement in the pipeline
Add this step at the end of your Jenkinsfile
post{
always{
...
echo "Stop appium server"
sh "kill \$(lsof -t -i :${APPIUM_PORT})"
}
success{
...
}
failure{
...
}
cleanup{
...
}
}
It should kill the hanging Appium server process and you can start the new Appium server again with the same port!
To see more details on this I already publish a blog here
How to start/stop Appium server in Jenkins Pipeline
Hope it helps
Related
I'm running Docker Desktop for MacOS and I don't know how to stop the Docker service. It runs all the time using up the MacBook battery.
On a simple search, there are docs showing how to stop the containers but not the docker service itself.
I might be missing something obvious, but is there a way to stop both Kubernetes and Docker service without having to kill the desktop app?
The docker desktop app starts a qemu vm, so the desktop app has no control over the PIDs.
To oversome the "situation" do the following:
open the Terminal app
edit the file ~/.bash_profile
add the following lines
#macro to kill the docker desktop app and the VM (excluding vmnetd -> it's a service)
function kdo() {
ps ax|grep -i docker|egrep -iv 'grep|com.docker.vmnetd'|awk '{print $1}'|xargs kill
}
save the file
Quit the terminal app and open it again.
Type kdo to kill all the dependend apps (hypervisor, docker daemon etc.)
You can open the Activy Monitor, select Docker and then use the Quit button.
Maybe you will need to use the Force Quit option.
I had been searching around for an answer to this too, as I noticed com.docker.hyperkit was taking >3GB memory and a lot of CPU, when the desktop app wasn't even opened on Mac OS X Catalina, Docker Desktop 3.0.4
Just as I was about kill -9, I noticed that quitting the docker app again actually did kill off every process except com.docker.vmnetd for whatever reason.
So I guess the solution here was... reopen and re-quit? I also made sure, of course, there were no running containers. I removed an old image too, unsure if that was related to it finally being able to fully quit.
com.docker.hyperkit taked > 8GB Memory . just run in terminal kill -9 PID
ex my process kill -9 71397
I have created emulator on remote machine (IP: 192.168.X.X) and that is working fine. After that I created Jenkins Job to execute Appium Test. I need to launch Emulator on remote machine (IP: 192.168.X.X) through Jenkins window batch commend.
See Windows Sysinternals' PsExec:
PsExec is a light-weight telnet-replacement that lets you execute processes on other systems, ...
Usage: psexec [\\computer[,computer2[,...] | #file]][-u user [-p psswd][-n s][-r servicename][-h][-l][-s|-e][-x][-i [session]][-c [-f|-v]][-w directory][-d][-<priority>][-a n,n,...] cmd [arguments]
I created a batch file that contain cmd command to execute Emulator and execute that batch file.
CMD command to invoke emulator
emulator -avd 'Emulator Name'
Emulator name you can get from command -> adb devices
Is it possible for this setting to work?
1) Ubuntu 14 with Jenkins, Genymotion, and Virtual Box installed
2) The job inside Jenkins will restore and run Genymotion from a command line following this tutorial: http://blog.genymobile.com/genymotion-jenkins-android-testing/
From my Mac, I tried to access the Jenkins website and run the build.
Firstly, Genymotion failed because it couldn't "connect to X server".
So, I installed Xvnc Plugin on Jenkins which solved the error.
Unfortunately, Genymotion still failed to start up with the error "Cannot get IP address".
Please note that I only have "ssh -X" access to the server.
I can manually start up Genymotion but the process was terminated when I logged off. As a result, I could not leave the GenyMotion run on the Server as suggested by this solution: Jenkins - Use Genymotion VM instead of Android Emulator
Any advice?
Here is the way to make Genymotion works on a continuous integration server.
First, the computer running Genymotion needs to respect the hardware requirements
You won't be able to run Genymotion if you don't have an X server running.
I don't think xVNC supports OpenGL so I advise you to run your standard X server.
You can launch the Xorg server by running startx.
Then you need to set your ssh connection in Jenkins without the -X parameter because we want the rendering to be done locally
Then you need to declare the environement variable DISPLAY to the default X client's value. Most of the time it is :0
This value will ask to open all the windows you launch through the ssh connexion into the first X client. It is the one running on the computer screen.
To check the DISPLAY value you need to enter, you need to access the computer physically and type echo $DISPLAY. Most of the time this value is :0
Also, if your computer is not compatible with the hardware requirements, you can use another computer on your network to run your tests thanks to the Jenkins nodes. Here is a good tutorial to set it up.
And finally, I want to mention we will soon release a command line tool for Genymotion and a Gradle Plugin that will allows you to control your Genymotion devices running during your tests directly from your build.gradle file.
It`s a bit late, but maybe this could help you out
### Get IP address of selected VM
VM_IP=`VBoxManage guestproperty get $VM_SELECTED androvm_ip_management | awk - F ": " '{print $2}'`
I found this here (repo) respectively here (slides)
I'm trying to run UI automation with a Jenkins job that runs on a windows VM as a jenkins slave, as a part of a CI pipeline.
I have a problem that the screen resolution is set to be very low (1024, 768)
how can I change the default resolution, so that when jenkins opens a new connection it will be with a larger resolution?
If your UI automation involves running Chrome, you might find it helpful to run Headless Chrome. That way, the screen resolution of the slave won't matter as you can specify the resolution you want to be used.
I was able to achieve this with these Chrome startup arguments running on a Windows Server Jenkins slave:
--headless --window-size=1920,1080
In my case, with Nightwatch, this is a snippet of the nightwatch.json file:
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions": {
"args": ["--window-size=1920,1080", "--headless"]
},
// ...
Do you have your webapp container started as a local service (tomcat or jenkins slave?). The point is that windows services cannot have GUI and it's even a miracle, that WebDriver somehow manages to open a 1024,768 window :)
Start your webapp container as a console application with a normal user.
I've got the same issue while trying to run UI tests on Jenkins
Problem: By default jenkins ran as windows service and have not access to run tests on desktop.
So fix:
run >> services.msc >> stop the system service Jenkins.exe
right click on Jenkins.exe >> properties >> startup type - Manual >> save
create an executable file (.bat, .exe, ...) save it somewhere and type there:
java -jar "C:\path\to\Jenkins\jenkins.war" --httpPort=8081
add shortcut of this executable file to windows autorun directory
It will run Jenkins on Desktop (non windows service) what allows run your UI tests there
Theoretically, running powerscript command as the build step:
set-displayresolution 1920 1080 -Force
should do it, but I have some problems with right now...
What has definitely worked: connect to your VM with RDP using desired resolution, then disconnect. The tests will run in the last resolution used.
I am facing the same issue. And found two different resolutions.
If your requirement is to see the chrome browser then open the command prompt and execute the below command
Java -jar jenkins.war
If your goal is just to change the resolution then add the below options and you can see the configure resolution(in the below example resolution is 1920,1080):-
ChromeOptions options = new ChromeOptions();
options.addArguments("enable-automation");
options.addArguments("--headless");
options.addArguments("--window-size=1920,1080");
options.addArguments("--no-sandbox");
options.addArguments("--disable-extensions");
options.addArguments("--dns-prefetch-disable");
options.addArguments("--disable-gpu");
I downloaded the native windows Jenkins package and installed it. On installation, it starts as a service in and shows in Task Manager, and also on going to the url localhost:8080. But then it stops. Here is what I get in my jenkins.out.log:
Running from: C:\Program Files (x86)\Jenkins\jenkins.war
webroot: EnvVars.masterEnvVars.get("JENKINS_HOME")
Jenkins home directory: C:\Program Files (x86)\Jenkins found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
Any ideas what could be causing this? I've checked throuh netstat that no other process is using the port 8080.
I found that the java.exe process was hung and keeping Jenkins from starting. I killed the java process and then jenkins service started up just fine.
Use process explorer.
It's possible to start jenkins via the command line using java -jar jenkins.war, however, because the process is started via the command line it will also end when that command window is closed.
A better way would be to start the service via jenkins.exe but you would have to remind doing that at every startup.
Ultimately we have settled with a batch script with the following content:
cd "C:\Program Files (x86)\Jenkins"
start javaw -jar jenkins.war >> outputFile.txt
adding start before calling javaw makes sure that the command window is not attached to the process started, making it possible to safely close down the command line.
Using >> outputFile.txt writes the command window feedback in a text file, making debugging a whole lot easier when Jenkins ever breaks down!
Save it in a batch script, schedule it with windows Task Scheduler to run at startup et voilà: properly set up Jenkins service.
Only make sure it doesn't stop at log-off.
I switched back to version 1.535 and now it works.
After my win vm system rebooted, the jenkins 1.625.2 service would just keep stopping.
It solved it by:
Kill java processes. Found some old java running dll's.
Uninstall old version of jdk1.6 that was there.
Cleaning java temp. files dir.
Then I was able to restart the service w/o problem.
if java.exe not visible in process
1.netstat -a -o -n find out the PID of your port
2.tasklist /FI “PID eq PID″
3.taskkill /F /PID 2600 kill the process