docker-selenium:具有Chrome和Firefox以及视频录制支持的Docker中的Selenium。 还要检查:

  • w0_728705
  • 1.4MB
  • zip
  • 0
  • VIP专享
  • 0
  • 2022-05-18 04:28
带有Chrome和Firefox的Docker中的Selenium 具有2个节点的Selenium服务器网格(chrome和firefox) mp4录像 VNC访问(用于调试容器) 谷歌Chrome稳定 google-chrome-beta:不再提供,但 google-chrome-unstable:已不再提供,但 火狐稳定最新 火狐稳定的 fluxbox(仍可在找到openbox窗口管理器) Selenium 3 docker run ... elgalu/selenium:latest Selenium 2 docker run ... elgalu/selenium:2不再维护 目的 该项目的目的是使尽可能简单快速地运行。 扩大了此目的,该项目使用此项目提供 -selenium。 还会在必要时将测试转发给云提供商(Sauce Labs,BrowserStack,TestingBot和LambdaTest)。 官方回购 注意和这一个具有相同的目的,但是在过去两年中这两个项目有很大的不同,一些主要区别是: 浏览器和网格都在此仓库中的同一容器中 支持 流程经理:此图像
# Selenium in Docker with Chrome and Firefox [![Build Status](]( "Travis CI") [![Docker Pulls](]( [![Docker](]( "Docker Badge") [![Analytics](]( "Analytics") [![Gitter](]( "Chat support") * selenium server grid with 2 nodes (chrome & firefox) * mp4 video recording * VNC access (useful for debugging the container) * google-chrome-stable * google-chrome-beta: no longer provided but [can still be found here][2.47.1m] * google-chrome-unstable: no longer provided but [can still be found here][2.47.1m] * firefox stable latest * firefox stable [last 18 versions can be found here][2.47.1m] * fluxbox (openbox window manager can still be found [here]( Selenium 3 `docker run ... elgalu/selenium:latest` ![docker-selenium-grid](./images/grid3_console.png) Selenium 2 `docker run ... elgalu/selenium:2` **no longer maintained** ### Purpose The purpose of this project is to have [Selenium][] running as simple and as fast as possible. This purpose is augmented by [Zalenium][] a project which uses this one to provide docker-selenium(s) on-demand. [Zalenium][] also forwards tests to a Cloud Provider (Sauce Labs, BrowserStack, TestingBot & LambdaTest) when necessary. <h2 id="official">Official repo</h2> Note [SeleniumHQ/docker-selenium]( and this one share the same purpose however both projects have diverged considerably in the last two years, some major differences are: * both browsers and also the grid are on the same container in this repo * support for [video recording](./docs/ * process manager: this image uses [supervisord]( while the official [uses bash]( Even though both projects share the same purpose is good to have alternatives, see also for example [docker-alpine-selenium]( Letting more than 1 docker-selenium project grow to be able to learn from each other's success or failures ultimately impacts the final users positively. This doesn't discard that at some point all selenium maintainers will sit together a sprint to coordinate some major changes and cleanup open issues and perhaps we might merge N similar projects in the future. ### Statistics [![ga-datastudio-docker-selenium](./images/ga-datastudio-docker-selenium.png)]( "Docker-Selenium usage stats v1") ### Alternatives If you don't require video recording we suggest to use either [Google Chrome in headless mode]( or [Firefox in headless mode]( We also recommend avoiding [PhantomJS]( as maintenance was stopped after Chrome & Firefox headless became available. You can also use a paid service like [Sauce Labs][sauce], [BrowserStack] or [LambdaTest][], note they offer free open source accounts and straightforward [integration with Travis CI]( ### Requisites This project is normally tested in the last version of Docker and docker-compose and also in the release candidates. To figure out the currently used specific versions it surely works on, see file [.travis.yml](./.travis.yml) example values: docker --version #=> 17.09.0-ce docker-compose --version #=> 1.16.1 If you need to use docker-machine to run docker (like for example on a Mac before the Docker native version 1.12), you also need to install VirtualBox and then run these commands to get started: ```sh docker-machine create --driver virtualbox default eval "$(docker-machine env default)" ``` You will need to run the second `eval` command for every new terminal window. ### Usage <h4 id="run"> Run</h4> 1. Pull the image and run the container docker pull elgalu/selenium #upgrades to latest if a newer version is available docker run -d --name=grid -p 4444:24444 -p 5900:25900 \ -e TZ="US/Pacific" -v /dev/shm:/dev/shm --privileged elgalu/selenium 2. Wait until the grid starts properly before starting the tests _(Optional but recommended)_ docker exec grid wait_all_done 30s # Or if docker exec is not available (eg. circleci) wget --retry-connrefused --no-check-certificate -T 30 http://localhost:4444/grid/console -O /dev/null After this, [Selenium][] will be up and ready to accept clients at `http://localhost:4444/wd/hub`. The grid's available browsers can be viewed by opening the console at `http://localhost:4444/grid/console`. If you are using Mac (OSX) or [Microsoft Windows]( `localhost` won't work unless you are in Docker Beta (version >= 1.12) If you are using Docker version <= 1.11 please find out the correct IP through `docker-machine ip default`. **Notes:** * The new default `VNC_PASSWORD=no` will make it VNC passwordless accessible. * Once this [docker feature]( is in place `wait_all_done` won't be necessary anymore. #### Stop Shutdown gracefully docker exec grid stop docker stop grid Shutdown immediately, no mercy docker rm -vf grid ### Docker Compose See [docker-compose](./docs/ ### Jenkins See [jenkins](./docs/ ### Parallel We now have a better suited product for this use case, is called [Zalenium][] This image is designed to run one test on each docker container but if you still want to run multiple tests in parallel you can still do so with [Zalenium][] If you want to limit yourself to this project, you still can. There are some ways to do it: 1. The recommended way is via [docker-compose](./docs/ and you should replace `mock` with your web service under test within the [docker-compose-tests.yml][] file. docker-compose -f docker-compose-tests.yml -p grid up --force-recreate docker-compose -f docker-compose-tests.yml -p grid scale mock=1 hub=1 chrome=3 firefox=3 1. The _(not recommended)_ way is by increasing `MAX_INSTANCES` and `MAX_SESSIONS` which now [defaults]( to 1. docker run -d --name=grid -p 4444:24444 -p 5900:25900 \ -v /dev/shm:/dev/shm --privileged \ -e MAX_INSTANCES=20 -e MAX_SESSIONS=20 \ elgalu/selenium The drawback is that all tests will run on the same desktop meaning the video recording will only capture the browser in the foreground but it's in the roadmap to make all this transparent, see issues [#78]( and [#77]( Another problem with increasing `MAX_INSTANCES` & `MAX_SESSIONS` is focus issues. So in this case is better scale up/down via [docker-compose](./docs/ ### OSX If you are in Mac, you need to get the correct IP of the docker machine. One of these two commands should work to get it: docker-machine ip default or former: boot2docker ip ### Screen size You can set a custom screen size at docker run tim