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
Related
I'm prototyping various deployment scenarios for my future delphi web projects. And as I'm going to build the nextgen killer app (...) , I investigated cloud deployment of a docker container for my backend API datasnap server.
As I was new to docker in general and relatively unfamiliar with linux, it was not straightforward.
But I managed to build an delphi 11 alexandria compatible PAServer image and deploy simple apps to my local docker desktop environment ( the radstudio/paserver docker hub images today are unfortunately 10.4.x only versions so no click and run possible...).
However, when deploying a default delphi datasnap webbroker server ( as console application ), the program returns to it's command line and waits for a 'start' instruction.
Sofar, I did't succeed in getting access to that program commandline interactively inside the docker CLI to enter that 'start' instruction ( or get access to the PAServer commandline to e.g. trigger a verbose session for the same matter ).
Yes, I can start the server by default and it 'fixes' the problem but sooner or later I will need this to be available ?
I tried one ( general ) suggestion ( get-apt install reptyr / reptyr PID ) to get access to running processes but it returns with errors and since I'm really newbie on linux/Docker I have no further ideas.
( FYI Deploying to windows, simply opens a command line window that stays available to type in )
# reptyr 83
[-] Timed out waiting for child stop.
Unable to attach to pid 83: Operation not permitted
#
( and an exception is raised in the IDE session 'Project raised exception class Stopped(user)(18)', but the session can be continued )
Ok, so if you start the docker container in interactive mode, the docker host commandline will convert into the container commandline, attached to the 'main' process with PID 1 ( I guess ).
docker run -it -p 8082:8082 -p 64211:64211 -p 80:80 mypaserverimage
connected to the PAServer command line.
But still it remains how to connect to the commandline of the subsequent PAServer deployed console application.
( can't seem to run the container that way from the docker desktop GUI. Need to run from docker host command line )
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
Iam automating an android app. I would like to know is there a way to run the tests parallely between emulator and a real device at the same time? Could you help me with the process? When i do adb devices, i see it recognizes "emulator-5554" and not the name that i gave while setting up the emulator.
First run command to get list of emulators are running
adb devices
enter image description here
in above image emulator-5554 and emulator-5556 are udid
Now, if you want to run parallel test in both devices, you need to start 2 appium servers as below with unique port and bootstarp port
first go to the directory where main.js is available using command line, and type below command to run 2 appium servers respectively
appium -p 1901 -U emulator-5554 -bp 2345
(This will open one appium server and it will return URI:0.0.0.0:1901
Now start another appium
appium -p 1902 -U emulator-5556 -bp 2345
(This will open another appium server and it will return URI:0.0.0.0:1902
Now, you are set and you can use both URL in different test and execute your TestNG
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