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

How can I use WebDriverManager in Docker? #406

Open
nshthshah opened this issue Mar 12, 2022 · 2 comments
Open

How can I use WebDriverManager in Docker? #406

nshthshah opened this issue Mar 12, 2022 · 2 comments

Comments

@nshthshah
Copy link

QAF Version

3.1.0

Expected behavior

It should support WDM with Docker with the latest version of WDM.
Reference: https://bonigarcia.dev/webdrivermanager/

@cjayswal
Copy link
Member

cjayswal commented Mar 18, 2022

The provided information is not enough to understand problem. However, for custom implementation, below are the steps you can follow:

@nshthshah
Copy link
Author

nshthshah commented Mar 21, 2022

WebDriverManager 5 is the ability to create browsers in Docker containers out of the box. The requirement to use this feature is to have installed a Docker Engine in the machine running the tests. To use it, we need to invoke the method browserInDocker() in conjunction with create() of a given manager. This way, WebDriverManager pulls the image from Docker Hub, starts the container, and instantiates the WebDriver object to use it. The following test shows a simple example using Chrome in Docker:

WebDriver driver;
WebDriverManager wdm = WebDriverManager.chromedriver().browserInDocker();

@BeforeEach
    void setupTest() {
        driver = wdm.create();
    }

    @AfterEach
    void teardown() {
        wdm.quit();
    }

Reference Link: https://bonigarcia.dev/webdrivermanager/#browsers-in-docker

Currently, there are two commands need to be executed,
docker run -d -p 4444:4444 --shm-size="2g" selenium/standalone-chrome:93.0

docker run -it --rm -v "$PWD":/usr/src/mymaven -v "$HOME/.m2":/root/.m2 -v "$PWD/target:/usr/src/mymaven/target" -w /usr/src/mymaven maven:3.8.2-openjdk-8 mvn test -Ddriver.name=chromeRemoteDriver -Dremote.server=<local_ip_address>

Here, you must have to pass <local_ip_address> and the driver will be RemoteWebDriver.

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

No branches or pull requests

2 participants