Запустить в selenoid браузер chrome на полный экран

Всем привет! Поднял докер selenoid и selenoid-ui. Написал тесты на java+selenium+selenide. Запускаю тесты, но не могу добиться, чтобы браузеры запускались в selenoid на полный экран.

Код запуска драйвера

        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setBrowserName("chrome");
        capabilities.setVersion("78.0");
        capabilities.setCapability("enableVNC", true);
        capabilities.setCapability("enableVideo", false);
        capabilities.setCapability("acceptInsecureCerts", true);

        WebDriver driver = null;
        try {
            driver = WebDriverPool.DEFAULT.getDriver(URI.create(HOST_HUB).toURL(), capabilities);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        WebDriverRunner.setWebDriver(driver);

        Configuration.baseUrl = HOST_SERVER;
        //Configuration.startMaximized = true;
        Configuration.browserSize = "1900x1200";
        Configuration.screenshots = false;

Получается, размер браузера все равно остаётся по умолчанию.

Привет.
Нужно поставить капабилити screenResolution. Например 1280x720x24.
Ну и растянуть потом браузер на этот размер.

1 лайк

Добавил в свой /etc/selenoid/browsers.json

{
    "chrome": {
        "default": "78.0",
        "versions": {
            "77.0": {
                "image": "selenoid/vnc_chrome:77.0",
                "port": "4444",
                "path": "/wd/hub",
                "selenoid:options": {"screenResolution": "1280x1024x24"}
            },
            "78.0": {
                "image": "selenoid/vnc_chrome:78.0",
                "port": "4444",
                "path": "/wd/hub",
                "selenoid:options": {"screenResolution": "1280x1024x24"}
            }
        }
    },
    "firefox": {
        "default": "70.0",
        "versions": {
            "69.0": {
                "image": "selenoid/vnc_firefox:69.0",
                "port": "4444",
                "path": "/wd/hub",
                "selenoid:options": {"screenResolution": "1280x1024x24"}
            },
            "70.0": {
                "image": "selenoid/vnc_firefox:70.0",
                "port": "4444",
                "path": "/wd/hub",
                "selenoid:options": {"screenResolution": "1280x1024x24"}
            }
        }
    },
    "opera": {
        "default": "65.0",
        "versions": {
            "64.0": {
                "image": "selenoid/vnc_opera:64.0",
                "port": "4444",
                "path": "/wd/hub",
                "selenoid:options": {"screenResolution": "1280x1024x24"}
            },
            "65.0": {
                "image": "selenoid/vnc_opera:65.0",
                "port": "4444",
                "path": "/wd/hub",
                "selenoid:options": {"screenResolution": "1280x1024x24"}
            }
        }
    }
}

Пересобрал контейнер selenoid

sysadm@ubuntu:~/docker_compose$ docker-compose stop selenoid
Stopping selenoid ... done
sysadm@ubuntu:~/docker_compose$ docker-compose rm selenoid
Going to remove selenoid
Are you sure? [yN] y
Removing selenoid ... done
sysadm@ubuntu:~/docker_compose$ docker-compose up --detach --build selenoid
Creating selenoid ... done

Затем в запуск также добавил

capabilities.setCapability("screenResolution","1920x1080x24");

Не помогло((( Что делаю не так?

Да ещё, мой docker-compose.yml файл

sysadm@ubuntu:~/docker_compose$ cat docker-compose.yml
version: '3'
services:
  selenoid:
    network_mode: bridge
    image: aerokube/selenoid:latest-release
    container_name: "selenoid"
    volumes:
      - "$PWD/selenoid:/etc/selenoid"
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "$PWD/selenoid/video:/opt/selenoid/video"
      - "$PWD/selenoid/logs:/opt/selenoid/logs"
    environment:
      - OVERRIDE_VIDEO_OUTPUT_DIR=$PWD/selenoid/video
    command: ["-conf", "/etc/selenoid/browsers.json", "-video-output-dir", "/opt/selenoid/video", "-log-output-dir", "/opt/selenoid/logs"]
    ports:
      - "4444:4444"
  selenoid-ui:
    image: aerokube/selenoid-ui
    container_name: "selenoid-ui"
    network_mode: bridge
    links:
      - selenoid
    ports:
      - "8080:8080"
    command: ["--selenoid-uri","http://selenoid:4444"]
  jenkins:
    image: "jenkins:latest"
    container_name: "jenkins"
    volumes:
      - "$PWD/jenkins:/var/jenkins_home"
      - "/var/run/docker.sock:/var/run/docker.sock"
    environment:
      JENKINS_HOST_HOME: "/home/sysadm/jenkins_home"
    ports:
      - 8088:8080
      - 5000:5000
      - 50000:50000

Разобрался

browsers.json

{
    "chrome": {
        "default": "78.0",
        "versions": {
            "77.0": {
                "image": "selenoid/vnc_chrome:77.0",
                "port": "4444",
                "path": "/",
                "screenResolution": "1920x1080x24"
            },
            "78.0": {
                "image": "selenoid/vnc_chrome:78.0",
                "port": "4444",
                "path": "/",
                "screenResolution": "1920x1080x24"
            }
        }
    },
    "firefox": {
        "default": "70.0",
        "versions": {
            "69.0": {
                "image": "selenoid/vnc_firefox:69.0",
                "port": "4444",
                "path": "/wd/hub",
                "screenResolution": "1920x1080x24"
            },
            "70.0": {
                "image": "selenoid/vnc_firefox:70.0",
                "port": "4444",
                "path": "/wd/hub",
                "screenResolution": "1920x1080x24"
            }
        }
    },
    "opera": {
        "default": "65.0",
        "versions": {
            "64.0": {
                "image": "selenoid/vnc_opera:64.0",
                "port": "4444",
                "path": "/",
                "screenResolution": "1920x1080x24"
            },
            "65.0": {
                "image": "selenoid/vnc_opera:65.0",
                "port": "4444",
                "path": "/",
                "screenResolution": "1920x1080x24"
            }
        }
    }
}

Запуск драйвера

        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setBrowserName("chrome");
        capabilities.setVersion("78.0");
        capabilities.setCapability("enableVNC", true);
        capabilities.setCapability("enableVideo", false);
        capabilities.setCapability("acceptInsecureCerts", true);

        WebDriver driver = null;
        try {
            driver = WebDriverPool.DEFAULT.getDriver(URI.create(HOST_HUB).toURL(), capabilities);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        driver.manage().window().setSize(new Dimension(1920, 1080));
        WebDriverRunner.setWebDriver(driver);

        Configuration.baseUrl = HOST_SERVER;
        Configuration.screenshots = false;

Так заработало)))

Рано я обрадовался. Если выбираю в качестве браузера opera, то в браузер уезжает

DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setBrowserName("opera");
        capabilities.setVersion("65.0");
        capabilities.setCapability("enableVNC", true);
        capabilities.setCapability("enableVideo", false);
        capabilities.setCapability("acceptInsecureCerts", true);

        WebDriver driver = null;
        try {
            driver = WebDriverPool.DEFAULT.getDriver(URI.create(HOST_HUB).toURL(), capabilities);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        driver.manage().window().setSize(new Dimension(1920, 1080));
        WebDriverRunner.setWebDriver(driver);

        Configuration.baseUrl = HOST_SERVER;
        Configuration.screenshots = false;

Подсказали решение добрые люди

driver.manage().window().setPosition(new Point(2,2));