qaf
qaf copied to clipboard
How can I use WebDriverManager in Docker?
QAF Version
3.1.0
Expected behavior
It should support WDM with Docker with the latest version of WDM. Reference: https://bonigarcia.dev/webdrivermanager/
The provided information is not enough to understand problem. However, for custom implementation, below are the steps you can follow:
- Disable default behavior by setting
manage.driver.executable=false
- Use driver listener to setup driver manager. Refer example form https://github.com/qmetry/qaf/issues/370#issuecomment-891169671 and driver listener
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.