Skip to content

useragent not apply on Chrome with docker Selenium #573

Closed

Description

@nono0481

What are you trying to achieve? (Expected behavior)

I want to set a UserAgent and MobileEmulation when i start a browser on selenium.
For this, i'm using ChromeOption class.

In fact, Google Chrome Driver has changed the option name to manipulate browser arguments. Since version 2.31, the option name is not chromeOptions but goog:chromeOptions :

When I change the name in ChromeOptions class, it's works fine.
=> Can you update the code please ?

What do you get instead? (Actual behavior)

The user-agent is set on chromeOptions but when the browser is stated the user-agent is not applied

How could the issue be reproduced? (Steps to reproduce)

$desired_capabilities = DesiredCapabilities::chrome();
$options = new ChromeOptions();
$options->addArguments(array('--user-agent=Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X Tests_Autos; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10'));
$desired_capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
$this->webDriver = RemoteWebDriver::create($selenium_server, $desired_capabilities);

Details

  • Php-webdriver version: 1.5
  • PHP version: 5.6
  • Selenium server version: 3.11
  • Operating system: Ubuntu 16.04
  • Browser used + version: Google Chrome 66.0.3359.181

Activity

  1. crazyfree commented on Jun 6, 2019

    @crazyfree

    I also can't set mobileEmulation

    $options = (new ChromeOptions)->addArguments([
                '--disable-gpu',
                '--headless'
            ]);
    
    $mobileEmulation = ['deviceName' => 'Nexus 5'];
    $options->setExperimentalOption('mobileEmulation', $mobileEmulation);
    
    return RemoteWebDriver::create( // selenium-hub
                'http://selenium-hub:4444/wd/hub',
                $desiredCapabilities
            );

    Details:

    • Facebook-webdriver version: 1.6
    • PHP version: 7.2.5
    • Selenium hub version: :3.141.59-neon
    • Operating system: Ubuntu 18.04
    • Browser used + version: Google Chrome 74.0.3729.108

    Kindly support

  2. OndraM commented on Nov 11, 2019

    @OndraM
    Collaborator

    This should be resolved by #673 and fixed in next php-webdriver release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions