selenium - "invalid argument: 'id' can not be string" when trying to switchToIFrame() in PHP

Solution:

It worked after adding this to the behat.yml

        capabilities:
          extra_capabilities:
            goog:chromeOptions:
              w3c: false

Answer

Solution:

For Drupal Mink I added the capability like so.

extensions:
    Drupal\MinkExtension:
      goutte: ~
      selenium2:
        wd_host: 'http://selenium:4444/wd/hub'
        browser: 'chrome'
        capabilities:
          ...
          extra_capabilities:
            chromeOptions:
              w3c: false
              ...

Answer

Solution:

As per the specifications of Switch To Frame:

The Switch To Frame command is used to select the current top-level browsing context or a child browsing context of the current browsing context to use as the current browsing context for subsequent commands.

The remote steps are:

  • Let id be the result of getting the property "id" from the parameters argument.

  • If id is not null, a Number object, or an Object that represents a web element, return error with error code invalid argument.

  • If the current browsing context is no longer open, return error with error code no such window.

  • Handle any user prompts and return its value if it is an error.

  • Run the substeps of the first matching condition and incase the id represents a web element:

    • Let element be the result of trying to get a known element by web element reference id.
    • If element is stale, return error with error code stale element reference.
    • If element is not a frame or iframe element, return error with error code no such frame.
    • Set the current browsing context to element’s nested browsing context.

Source