New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can no longer specify browserName with Grid desiredcaps #6412

Closed
jessehudl opened this Issue Apr 15, 2016 · 2 comments

Comments

Projects
None yet
4 participants
@jessehudl

jessehudl commented Apr 15, 2016

The problem

Appium v1.5 no longer accepts a non-empty browserName desired capability, which breaks compatibility with Grid and contradicts the Appium documentation.

Environment

  • Appium version (or git revision) that exhibits the issue: 1.5+
  • Last Appium version that did not exhibit the issue (if applicable): 1.4
  • Desktop OS/version used to run Appium: OSX 10.11.4
  • Node.js version (unless using Appium.app|exe): 4.2.1
  • Mobile platform/version under test: Any
  • Real device or emulator/simulator: Both
  • Appium CLI or Appium.app|exe: CLI

Details

The Selenium Grid server matches capabilities to nodes using browserName, version, and platform. The session is then passed to the matching node and Appium looks for deviceName, platformName, and app. Appium's Grid docs also specify this, and recommend using a node configuration file with the following capabilities:

          "browserName": "<e.g._iPhone5_or_iPad4>",
          "version":"<version_of_iOS_e.g._7.1>",
          "maxInstances": 1,
          "platform":"<platform_e.g._MAC_or_ANDROID>"

browserName being used as a way to specify the device or simulator for the Grid to match the node on (e.g. iPhone 5). It appears in Appium 1.5, this is no longer working as reported by this bug. Now this fails with:

WebDriverException: Message: A new session could not be created. Details: The desiredCapabilities object was not valid for the following reason(s): browserName iPhone 6S is not included in the list.

The workaround from #6177 is to use an empty browserName capability, but in doing so the Grid is no longer able to match nodes properly since it's only matching based on version, and platform, meaning it will open anything that matches (iPad, iPhone, Nexus, etc.) The workarounds would be either giving each device a unique version for the Grid to match (which then doesn't match deviceVersion and confusing), or use a workaround capability like applicationName. Neither are backwards compatible with previous configurations or the documentation and make working with the Grid much more difficult.

Link to Appium logs

https://gist.github.com/jessehudl/ed5a879f478a74f8071d327ddc067a87

Code To Reproduce Issue [ Good To Have ]

Register a v1.5+ Appium node with a Selenium Grid hub using a node config like the one from the Appium documentation - http://appium.io/slate/en/master/?ruby#grid-node-configuration-example-json-file

Try to start a session (python example):

In [43]: driver = webdriver.Remote('http://grid01:4445/wd/hub', {'platform':'MAC', 'deviceName':'iPhone 6s', 'browserName':'iPhone 6S', 'platformName':'iOS'})                       ---------------------------------------------------------------------------
WebDriverException                        Traceback (most recent call last)
<ipython-input-43-2142773a6c76> in <module>()
----> 1 driver = webdriver.Remote('http://grid01:4445/wd/hub', {'platform':'MAC', 'deviceName':'iPhone 6s', 'browserName':'iPhone 6S', 'platformName':'iOS'})

/usr/local/lib/python3.5/site-packages/appium/webdriver/webdriver.py in __init__(self, command_executor, desired_capabilities, browser_profile, proxy, keep_alive)
     34                  desired_capabilities=None, browser_profile=None, proxy=None, keep_alive=False):
     35
---> 36         super(WebDriver, self).__init__(command_executor, desired_capabilities, browser_profile, proxy, keep_alive)
     37
     38         if self.command_executor is not None:

/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py in __init__(self, command_executor, desired_capabilities, browser_profile, proxy, keep_alive, file_detector)
     89         self.error_handler = ErrorHandler()
     90         self.start_client()
---> 91         self.start_session(desired_capabilities, browser_profile)
     92         self._switch_to = SwitchTo(self)
     93         self._mobile = Mobile(self)

/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py in start_session(self, desired_capabilities, browser_profile)
    171             desired_capabilities['firefox_profile'] = browser_profile.encoded
    172         response = self.execute(Command.NEW_SESSION, {
--> 173             'desiredCapabilities': desired_capabilities,
    174         })
    175         self.session_id = response['sessionId']

/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py in execute(self, driver_command, params)
    231         response = self.command_executor.execute(driver_command, params)
    232         if response:
--> 233             self.error_handler.check_response(response)
    234             response['value'] = self._unwrap_value(
    235                 response.get('value', None))

/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py in check_response(self, response)
    192         elif exception_class == UnexpectedAlertPresentException and 'alert' in value:
    193             raise exception_class(message, screen, stacktrace, value['alert'].get('text'))
--> 194         raise exception_class(message, screen, stacktrace)
    195
    196     def _value_or_default(self, obj, key, default):

WebDriverException: Message: A new session could not be created. Details: The desiredCapabilities object was not valid for the following reason(s): browserName iPhone 6S is not included in the list.

@triager triager added the NeedsTriage label Apr 15, 2016

@jessehudl jessehudl changed the title from Cannot no longer specify browserName with Grid desiredcaps to Can no longer specify browserName with Grid desiredcaps Apr 15, 2016

@jessehudl

This comment has been minimized.

jessehudl commented Apr 15, 2016

I think I've figured out the cause here. appium/appium-base-driver@b305420 added desired capability checking. The ios driver is only accepting Safari as an acceptable browserName - https://github.com/appium/appium-ios-driver/blob/721bcd93011d6451d3e47e50dcb0447a87466802/lib/desired-caps.js#L9-L12

The driver needs to be able to accept any browserName when using the grid since that is how the Grid matches a node, even if it's only using an app. I hope to submit a PR to remove the specific Safari requirement.

@michaelmendoza42

This comment has been minimized.

michaelmendoza42 commented Apr 21, 2016

Thank you for documenting this. I was having the same issue and it was driving me crazy.

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