douwei1174 2019-07-06 22:27
浏览 99

Selenium php-webdriver忽略所有参数和扩展名

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
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何实验stm32主通道和互补通道独立输出
    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题