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");
Related
I am trying to containerize the automation tests to run in docker environment. When the build runs on the automation code, it creates an docker image and updates in DTR. I have a separate jenkins pipeline which runs the automation commands in the docker image and uploads the results in the workspace. All of this setup working in fine in non-docker environment (ie., on local mac terminal), but the same tests are failing in docker environment. I am trying to figure out a solution, but it doesn't seem to work.
I get below errors when running the protractor tests in docker environment
After # test/cucumber/stepDefinitions/hooks.ts:31
WebDriverError: invalid session id
(Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Linux 4.9.125-linuxkit x86_64)
I built my docker image FROM circleci/node (https://hub.docker.com/r/circleci/node/) and this image has required libraries installed (node, npm,yarn, chrome and chrome drivers).
Before running the tests I made sure the protractor, cucumber and webdriver modules are installed.
Even then, i am trying to install chrome and chrome driver while building the image using apt-get package manager.
The docker env is on Debian GNU/Linux 9 \n \l
The chrome driver version is
73.0.3683.75-1~deb9u1
Google Chrome version is 73.0.3683.103
I am running headless
Making sure the webdriver manager is updated before starting it
Web driver version 13.0
Running below:
webdriver-manager update --ignore_ssl --versions.chrome 73.0.3683.75-1~deb9u1
webdriver-manager start --detach
protractor test/cucumber/config/cucumberConfig.ts
I expect all the tests to run in docker environment in the same way it ran in mac terminal, but getting below errors:
And Log out application # test/cucumber/stepDefinitions/common-step-def.ts:64
✖ After # test/cucumber/stepDefinitions/hooks.ts:31
WebDriverError: invalid session id
(Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Linux 4.9.125-linuxkit x86_64)
at Object.checkLegacyResponse (/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/node_modules/selenium-webdriver/lib/http.js:441:30)
at
at process._tickCallback (internal/process/next_tick.js:189:7)
From: Task: WebDriver.takeScreenshot()
at thenableWebDriverProxy.schedule (/node_modules/selenium-webdriver/lib/webdriver.js:807:17)
at thenableWebDriverProxy.takeScreenshot (/node_modules/selenium-webdriver/lib/webdriver.js:1085:17)
at run (/node_modules/protractor/built/browser.js:59:33)
at ProtractorBrowser.to.(anonymous function) [as takeScreenshot] (/node_modules/protractor/built/browser.js:67:16)
at World. (/test/cucumber/stepDefinitions/hooks.ts:36:17)
Any thoughts?
I run into the same problem recently. It looks like browser instance can't start due to some reason. In my case adding --disable-dev-shm-usage to chrome-options solved the issue.
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-dev-shm-usage");
ChromeDriver driver = new ChromeDriver(options);
Why this helps:
By default, Docker runs a container with a /dev/shm shared memory space 64MB. This is typically too small for Chrome and will cause Chrome to crash when rendering large pages. To fix, run the container with docker run --shm-size=1gb to increase the size of /dev/shm. Since Chrome 65, this is no longer necessary. Instead, launch the browser with the --disable-dev-shm-usage flag:
~ Google troubleshooting guide
According to that, another idea would be to try using --shm-size=1gb when running the container if you really want to use /dev/shm.
May be check the Chrome version compatible with the OS version you are using in the Docker.
From the logs it seems the page is not even loaded or crashed on loading. Either it requires more memory to load the page or the chromes extensions might have been enabled.
try adding these options to config
chromeOptions: {
args: [
'incognito',
'disable-extensions',
'disable-infobars',
]
}
I have installed latest jenkins.war from
https://updates.jenkins-ci.org/download/war/
after that I have triggered that WAR file as
java -jar jenkins.war in command prompt.
I have attached the screen shots of the same.
As I could understand from the logs that, port which jenkins trying to operate on is already in use.
would appreciate the any help on this!
By default, Jenkins will bind on port 8080 (listening address will be http://localhost:8080), you can change this port by editing the jenkins.xml file that is located in the directory where you installed Jenkins.
Change it for another value and relaunch. (or try to find who is already listening on this 8080 port, probably a web server)
By the way, instead of downloading the jenkins.war, it would be better to use the native windows installer, that will install/start jenkins as a service.
You can change the port without editing jenkins.xml. This can be useful when you are doing an initial setup where you don't have a jenkins.xml yet.
java -jar jenkins.war --httpPort=<your port>
You can also run Jenkins this way with an existing jenkins.xml. In my case I can access the Jenkins UI using both ports. When one of both ports is already used by the system like in your case, Jenkins won't start.
Copdenvy's shellinabox runner allows you to start a shell in the browser in which you can compile and run your code. This is fine for applications that are console based. Is it possible to run an X Windows application in the cloud and see the graphical window?
Setting the DISPLAY variable in the shell to that of your Linux workstation could work, though it relies on you being in control of the local network for things like NAT and firewall settings. The attraction of the cloud IDE is that you only need a browser and an https connection.
Can you ssh -X into the Docker container from an X capable source? Where would you find the URL? How would you manage the ssh keys?
If you look at the Java/Swing "VNC + Java 7" runner for example you'll see that you're able to run an application which is using X DISPLAY through VNC. Codenvy supplies a web based X Windows environment that you can access by clicking on the hyperlink that is shown underneath the Console window, to the left of the Timeout counter. You can then look at the Docker recipe used to start this sample.
SSH in the docker container could be managed in Codenvy 3.x if you install inside the VM the sshd daemon and export the ssh/22 port. In upcoming Codenvy SaaS 4.x ssh will be enabled without any configuration.
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 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