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 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用