Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress GUI #29

Closed
silentlight opened this issue Jan 13, 2018 · 16 comments
Closed

Cypress GUI #29

silentlight opened this issue Jan 13, 2018 · 16 comments

Comments

@silentlight
Copy link

Hello,

Is it possible to run Cypress GUI from inside the container?
My development environment is dockerized but I would still love to use your brilliant GUI.

Thanks

@brian-mann
Copy link
Member

Yes but you'll need to install VNC and connect in order to "see" what's going on. It' won't be very fun trying to use the browser and develop there though. :-/

Until Cypress supports launching a remote browser we don't really recommend it. Instead it makes more sense for you to host your server / code in Docker, but just expose that server to the outside world and then use your normally installed browser to connect to it.

@silentlight
Copy link
Author

Thank you for fast response!

If thats not a problem, I will need a little guidance from you on this one.
When I start my dev environment using docker-compose up my web app is available under localhost:3000. If I understood it correctly, I will need to create a new service inside my docker-compose.yml for which endpoint will be cypress open. Then I will need to expose some port and I will be able to connect to Cypress GUI via my browser. Is that correct?

@silentlight
Copy link
Author

I made some progress, but I still have problems with this setup.
I set the port in cypress.json to 34611. Then I exposed that port in my docker-compose.yml file. After running cypress open on the container witn my web app, I navigate in the browser to http://localhost:34611 and I see a page with this message:
Whoops, we can't run your tests. This browser was not launched through Cypress. Tests cannot run.

What am I missing?

@silentlight
Copy link
Author

In addition, in my docker container log I find this:

Xlib:  extension "RANDR" missing on display ":99".
Xlib:  extension "RANDR" missing on display ":99".
libudev: udev_has_devtmpfs: name_to_handle_at on /dev: Operation not permitted

@brian-mann
Copy link
Member

@silentlight the Xlib stuff is nothing - its normal part of XVFB working.

You actually won't be able to get this working I'm afraid. Cypress itself has to launch your browser in a very specific way - with flags and a custom profile else it won't work. Until Cypress has the ability to launch remote browsers not installed directly on the OS this won't work - sorry.

What I was suggesting was actually the inverse - don't try to run cypress open through your Docker container. Just install Cypress on the host operating system - and then just expose your webserver from docker to the host via port mapping. Then you'll be able to cy.visit and everything will just work.

@cyborgmarina
Copy link

There seems to be some security issues regarding running X inside a docker container, but you can do it with Firefox for instance:

https://github.com/splattael/docker-firefox
Maybe just by replacing "firefox" with "cypress open" it would work? I don't know.

There's also this repo that solves some of the security issues I mentioned, but I haven't tried.
https://github.com/mviereck/x11docker

@bahmutov
Copy link
Contributor

bahmutov commented Feb 8, 2018

I have done experiments running VNC from Docker so you can look into the container running Cypress here https://github.com/cypress-io/browser-connect-experiment but this is tricky.

@bahmutov bahmutov closed this as completed Feb 8, 2018
@omaressameldin
Copy link

@bahmutov this link you posted is not working :( also can someone tell me how to run cy.visit() from the stanalone gui app?

@bahmutov
Copy link
Contributor

@omaressameldin good catch, repo was private, I just made it public

@omaressameldin
Copy link

@bahmutov thanks :)

@omaressameldin
Copy link

also i ended up doing it this way which is simple just run docker using these options and it works
docker run -it -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY [cypress_container] npx cypress open and if you get this error No protocol specified you just run this in your host machine xhost local:root This will only work ofcourse if your image already has the node modules installed and everything

@prescottprue
Copy link

I was able to get this working with @omaressameldin. It would be awesome to see a guide for doing this.

x11 is pretty annoying to deal with, so it would be awesome to have access to the server that is hosting application (so that the port could be exposed)

@walkerrandolphsmith
Copy link

@brian-mann is there a ticket for supporting launching a remote browser and is it on the cypress team's roadmap? If not is there any information that you can provide that may help the community issue a pr and make it happen?

@seyfer
Copy link

seyfer commented Jan 3, 2020

@walkerrandolphsmith yes I have added one cypress-io/cypress#5985

@gaugau3000
Copy link

gaugau3000 commented Apr 14, 2020

In addition of the answer of @omaressameldin

also i ended up doing it this way which is simple just run docker using these options and it works
docker run -it -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY [cypress_container] npx cypress open and if you get this error No protocol specified you just run this in your host machine xhost local:root This will only work ofcourse if your image already has the node modules installed and everything

if you are on chromium you should need to give this extra environment variables to make it work (contrib from @milesrichardson) .

docker run ... \
 -e QT_X11_NO_MITSHM=1 \
 -e _X11_NO_MITSHM=1 \
 -e _MITSHM=0 \

@bchenSyd
Copy link

is there a ticket for supporting launching a remote browser and is it on the cypress team's roadmap? If not is there any information that you can provide that may help the community issue a pr and make it happen?

inject scripts in a remote browser.. might involve setting up another nodejs sever on the target machine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants