Hi,
My test are running in docker container in headless mode . I want ti run in display mode to debug it. I am not finding way to do that. Here are steps i do:
1. start docker using docker-compose up
version: "2"
services:
test-ng-environment:
image: "test-ng-environment:latest"
build:
context: "."
dockerfile: "Dockerfile"
command: "sleep infinity"
volumes:
# hardcoded to live next to the code repo
- "../code:/my_code"
- "./m2:/root/.m2"
- "/var/run/docker.sock:/var/run/docker.sock"
cap_add:
# this is required for chrome to be able to start in sandbox mode
- SYS_ADMIN
network_mode: "bridge"
shm_size: '2gb'
2. Run environment bash , go to mounted directory and run test using :
xvfb-run -a mvn test --batch-mode --errors --fail-at-end --show-version -Dtest.browser=chrome -Durl="${TEST_URL}" -Dusername=testuser -Dpassword="${TEST_PASSWORD}"
Test run fine in headless mode. I removed xvfb-run -a and run test using mvn test only. I got error :
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
Here is method to start chrome driver:
public WebDriver setupChromeDriver() {
final boolean headlessMode = prop.getProperty("mode.chromeheadless", "").equals("true");
ChromeOptions options = new ChromeOptions();
Map<String, Object> prefs = new HashMap<>();
prefs.put("credentials_enable_service", false);
prefs.put("profile.password_manager_enabled", false);
options.setExperimentalOption("prefs", prefs);
options.addArguments("disable-infobars");
options.addArguments("disable-extensions");
if (headlessMode) {
options.addArguments("headless");
}
options.setCapability(ChromeOptions.CAPABILITY, options);
driver = new ChromeDriver(options);
// Resize the current window to the given dimension
driver.manage().window().setPosition(new Point(0, 0));
driver.manage().window().setSize(d);
}
Thanks !!