My current project is java selenium (with selenide framework) auto-tests with gradle and junit.
Now, I want to wrap my whole project to docker container, to make it possible to run it on other machines using only docker.
As I see it:
What am I suppose to do?
A saw a lot of tutorials about browsers in containers, selenoid, etc.(which is cool).
But I can't find a solution for my question.
Thanks!
What you need to do is:
Create a docker image that has Java, Chrome, selenium, gradle, junit, etc
Once you have the image, run it on your local on any port example: 4444
Switch to RemoteWebdriver
public static String remote_url_chrome = "http://localhost:4444/wd/hub";
ChromeOptions options = new ChromeOptions();
driver.set(new RemoteWebDriver(new URL(remote_url_chrome), options));
Suggest to run tests as docker-compose
multi-container application.
It will have 2 services in docker-compose
as i see it:
browser
- based on selenium Chrome browser image tests
- based on custom image extending java
base image . Custom image Dockerfile
should have gradle
installed and tests jar file built in it. Tests should drive Chrome browser using RemoteWebDriver
initialized as below (note browser
hostname where remote Chrome is listening).
public void createChromeDriverForRemote(){
WebDriver driver = new RemoteWebDriver("http://browser:4444/wd/hub", DesiredCapabilities.chrome());
}
See quick start here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.