Is there a way to launch chrome in non headless mode from a docker container?
I have a node application inside a docker container and a headless chrome container where i can connect to. All works fine so far. To demonstrate what puppeteer is doing i want to launch a chrome in non headless mode on the host system. Is this possible?
You can start Chromium manually on your host machine and then connect to its WebSocket port using puppeteer.connect() - https://pptr.dev/#?product=Puppeteer&version=v1.8.0&show=api-puppeteerconnectoptions . Don't forgot to open the WS port to container.
We also experimented with running Puppeteer in non-headless mode inside the Docker container using XVFB (X virtual framebuffer) and noVNC (https://github.com/novnc/noVNC) to display whats on the screen at HTML page served from the container. But that's not ideal for debugging.
If you just want to see which pages are opened and their screenshots you could use live-view https://github.com/apifytech/apify-js#puppeteer-live-view we build exactly for this use case.
Related
I run my nodejs 8.9.4 app (which is not a server) in a remote Kubernetes cluster with node --inspect=0.0.0.0:9229 app.js. I then port-forward 9229 on my machine. Finally, I access to chrome inspector and I can see my source code. I tried to run with --inspect-brk and I successfuly debugged my app. But I can't take heap snapshot: the button is disabled. I can't understand why.
Disabled take snapshot button
My advice is to :
Update chrome to latest version and relaunched it (also it is good to download Chrome Canary )
Restart node
Open chrome://inspect and added localhost: port number -9229 update connection in chrome.
Take a look: debugging-nodejs, memory-leaks-nodejs.
Running chrome on docker machines is only possible when chrome is headless. Unfortunately, headless chrome can't ignore certificate errors which prevents my tests from running.
I'm trying to run an already working NodeJS e2e test environment on a docker container. Most of the tests pass but when a site requires a certificate it can't be accessed. On none headless chrome I can simply ignore the certification error.
The base docker image installed on the container is Node:8
{
browserName: 'chrome',
chromeOptions: {
binary: puppeteer.executablePath(),
args: [
'--lang=en-US','--headless','--no-sandbox','--ignore-certificate-errors'
]
}
The expected result is to either run chrome with gui on a docker container or somehow ignore the server certificate errors in headless chrome.
Use Xvfb. This will allow you to use Chrome with GUI.
The idea is simple: you use virtual desktop. Configuring multiple desktops / displays on a standalone VM took some efforts. With Docker it is simple.
Some examples:
http://www.mattzeunert.com/2018/07/21/running-headful-chrome-on-ubuntu-server.html
https://medium.com/dot-debug/running-chrome-in-a-docker-container-a55e7f4da4a8
Another way (described here by Nils De Moor) is to let the docker container connect to your local machine's X server.
Say your ip address is 192.168.0.2.
You can set up a tunnel to you X display on i.e. port 6010, (which corresponds to display 192.168.0.2:10) with socat. For security, the range argument asks socat to only accept connections from your machine's IP address.
socat TCP-LISTEN:6010,reuseaddr,fork,range=192.168.0.2/32 UNIX-CLIENT:\"$DISPLAY\" &
Now you can set the DISPLAY variable inside the docker container with -e when you start it.
docker run -e DISPLAY=192.168.0.2:10 gns3/xeyes
In the case of chrome there are some more complications, described in the linked post, because chrome requires some more privileges (i.e. add --privileged )
I am running a node js server within Docker and I would like to be able to connect chrome dev tools on my host to node js on docker for debugging purpsoses.
This seems to be possible as I followed the post here : Why Chrome can't inspect nodejs code in Docker container?
In fact by binding the ports 9229:9229 on the host and within docker to each other and in docker running the command when I start the node js
node --inspect-brk=[0.0.0.0] app
I am able to connect chrome dev tools to node js, however none of my break points work - I can only see the console logs within chrome.
How can I get my breakpoints to work? What am I missing here?
To answer my own question I never got the above to work but I did manage to debug within a docker container using VS code.
There is another solution that I used here: https://keylocation.sg/our-tech/debugging-nodejs-in-docker-using-node-inspector
Looks like someone else found a solution here too: Why Chrome can't inspect nodejs code in Docker container?
I have a NodeJs app running on a docker container on a remote server. I can access the app on the browser. I'm also able to deploy to my app using PhpStorm and its remote server connection.
However, I tried to use the remote NodeJs debug tool of PhpStorm and it doesn't work. I always get connection refused.
I know the debug port is open because I check the docker containers and the 5858 is open. This port is also oppened on the host. And this is also the port I set for the debug.
package.json:
"scripts": {
"start": "nodemon --debug=5858 index.js myApp"
}
I don't know if PhpStorm is the best solution to debug this kind of app. So if someone has a better idea please let me know.
Thanks!
After further searching I found this great repository:
https://github.com/seelio/node-inspector-docker
It seems to me the easier way to make the app running and debug it.
Definitely node-inspector,
I had to do the same for an app in microservices and clusters/workers
just in case you need it: clustered apps with node-inspector
You can use intelij IDEA as IDE
It support running app directly from docker and allows you to debug apps easily.
once configured with your docker image its done.
next time just click run and it will start quickly nodejs inside your docker and show logs etc all just like we do with local node instance
https://www.jetbrains.com/help/idea/2016.3/running-and-debugging-node-js.html#node_docker_run_debug
Its EAP and communitiy editions are always is free
Currently I'm using Jenkins installed on Linux machine for automated testing Firefox and Chrome browsers.
My company want to start automated testing on IE. Is there any way to add virtual machine with Windows 7 os to Jenkins architecture (new node?) to run all tests from one Jenkins instance?
I want to have tasks with different builds :
- first to run tests on Chrome driver using mvn (works fine now)
- second to run tests on FF driver (works fine now)
- third to run tests on IE driver (need to be created)
If there is no way to do this should I prepare Windows machine with new Jenkins installation?
You can do this by using the hub option on your main selenium server
java -jar selenium-server-standalone-2.25.0.jar -role hub -hubHost localhost -hubPort 4444
And then on your windows machine (this is a chrome example as I am on my mac) do something like this
java -jar selenium-server-standalone-2.25.0.jar -role node -hubHost <ip of hub> -hubPort 4444\
-browser "browserName=chrome,maxinstance=2,platform=MAC" \
-Dwebdriver.chrome.driver="driver/chromedriver"
You will also need to download the iedriver to make it work selenium downloads
You then connect to selenium through port 4444 (as a convention) on the main selenium server and it places requests accordingly