0

UPDATED: I will leave the question open in case someone can explain what I was doing wrong. I didn't fix the issue, but I achieved result after switching from "selenium-hub + chrome node" to "standalone chrome" image in docker-compose.yaml


I'm using facebook/php-webdriver to run Chrome test with Selenium. Here is the simple code example:

I'm using SeleniumHQ/docker-selenium to run Selenium. So docker-compose.yaml is like:

...
    selenium-hub:
        container_name: selenium-hub
        image: selenium/hub:latest
        ports:
            - "4444:4444"
    chrome:
        container_name: chrome
        image: selenium/node-chrome:latest
        volumes:
            - /dev/shm:/dev/shm
        depends_on:
            - selenium-hub
        environment:
           - HUB_HOST=selenium-hub
           - HUB_PORT=4444
           - SCREEN_WIDTH=1280 
           - SCREEN_HEIGHT=800
           - SCREEN_DEPTH=24
        entrypoint: bash -c 'SE_OPTS="-host $$HOSTNAME" /opt/bin/entry_point.sh'
...

PHP code:

        $options = (new ChromeOptions())
            ->addArguments([
            '--window-size=640x480',
            ]);
        $capabilities = DesiredCapabilities::chrome();
        $capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
        $driver = RemoteWebDriver::create('http://selenium-hub:4444/wd/hub/', $capabilities, 5000);
        $driver->get('chrome://version/');
        header("Content-Type: image/jpeg");
        echo $driver->takeScreenshot();
        $driver->quit();

For some reason params in addArguments() doesn't have any impact - the outcome is always the same no matter what was set in the method addArguments(). It is always something like this

enter image description here

Whatever I'll put to addArguments() nothing will change.

Any ideas are appreciated.

Environment information:

  • Php-webdriver version: 1.7.1
  • PHP version: 7.2.19
  • Selenium server version: 3.141.59
  • Operating system: Alpine Linux
  • Browser used + version: Chrome 75.0.3770.90
  • SeleniumHQ/docker-selenium: 3.141.59
Yevgen
  • 1,239
  • 3
  • 15
  • 30

2 Answers2

0

I have had the same issue with Java Selenium tests. After couple of hours I have figured out, why no arguments were passed to chrome. You can try to pass whatever arguments ("aaaaa=bbbbb",...), but no args are passed.

Solution is to upgrade webdriver (not chromedriver). In my Java case, updating version numbers in Maven's POM file of all "org.seleniumhq.selenium" dependencies.

0

Thanks the composer update helped! Before these I fixed in the composer.json file to get a version over 1.8 Спасибо помогло обновление composer update! Перед эти исправил в файле composer.json на получение версии более 1.8

{
    "require": {
        "php-webdriver/webdriver": ">1.8"
    }
}

Установилась версия 1.11