selenium icon indicating copy to clipboard operation
selenium copied to clipboard

Error parsing capabilities.chromeOptions.mobileEmulation.deviceMetrics.width in Selenium 3.5.0

Open stephenash opened this issue 9 years ago • 3 comments

Meta -

OS: macOS 10.12.6 Selenium Version: 3.5.0 Browser: Chrome Browser Version: 60.0.3112.101 (Official Build) (64-bit)

Expected Behavior -

Setting capabilities.chromeOptions.mobileEmulation.deviceMetrics.width = <int> does not raise an error. This behavior worked in Selenium v3.4.0.

Actual Behavior -

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot parse capability: chromeOptions
from unknown error: cannot parse mobileEmulation
from unknown error: 'width' must be an integer
  (Driver info: chromedriver=2.31.488774 (7e15618d1bf16df8bf0ecf2914ed1964a387ba0b),platform=Mac OS X 10.12.6 x86_64) (WARNING: The server did not provide any stacktrace information)

Steps to reproduce -

  1. Start a selenium server process
$ java -Dwebdriver.chrome.driver=.selenium/chromedriver/2.31-x64-chromedriver -jar .selenium/selenium-server/3.5.0-server.jar
  1. Invoke below python script that will connect to the started selenium server instance and set the capabilities as listed above.
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

capabilities = {
  "browserName": "chrome",
  "chromeOptions": {
    "args": [
      "disable-infobars",
      "incognito"
    ],
    "mobileEmulation": {
      "deviceMetrics": {
        "width": 360,
        "height": 640,
        "pixelRatio": 3
      },
      "userAgent": "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Mobile Safari/537.36"
    }
  },
  "platform_tag": "",
  "build": "defaultbuild 2017-8-18 13:00",
  "tunnelIdentifier": "pandora.fciis.net"
}

driver = webdriver.Remote(
  command_executor='http://127.0.0.1:4444/wd/hub',
  desired_capabilities=capabilities)

driver.get("http://www.python.org")
driver.close()

The script used above is saved in https://gist.github.com/stephenash/764d21034179d55fe7472dfe1ddd5620. That gist also contains the server output when using selenium v3.4.0 vs v3.5.0, and the full error output for the client.py script when connecting to v3.5.0.

Note that while this example uses python, I've been able to reproduce with nodejs (https://github.com/vvo/selenium-standalone/issues/299#issuecomment-323449530) as well.

stephenash avatar Aug 19 '17 15:08 stephenash

I believe there's already an issue logged about this, but it appears that server is converting Integers to Floats. I'm leaving this open until I can find it.

lmtierney avatar Aug 21 '17 01:08 lmtierney

I believe there is a problem with the new pass-through mode. If I run selenium-server with -enablePassThrough false it doesn't produce this error.

bayandin avatar Aug 21 '17 06:08 bayandin

Moving this issue to #4445

shs96c avatar Aug 21 '17 08:08 shs96c