Skip to content

[1.8.0] Illegal key values seen in w3c capabilities: [platform] #676

Closed

Activity

  1. OnkelTem commented on Nov 14, 2019

    @OnkelTem

    Same here.

    After quick debugging I found that this 1.8.x addition to \Facebook\WebDriver\Remote\RemoteWebDriver::create:

    // W3C
    $parameters = [
        'capabilities' => [
            'firstMatch' => [static::convertCapabilitiesToW3c($desired_capabilities->toArray())],
        ],
    ];
    
    if ($required_capabilities !== null && $required_capabilities_array = $required_capabilities->toArray()) {
        $parameters['capabilities']['alwaysMatch'] = static::convertCapabilitiesToW3c($required_capabilities_array);
    }

    is leading to the problem.

    So it's probably related to W3C WebDriver protocol.

    UPDATE.
    Yep. The real problem is actually displayed in the error message: there is not such key as platform if using W3C WebDriver protocol (which is now the default one, eh?)
    The spec expects it to be platformName: https://w3c.github.io/webdriver/#capabilities

    In my code I do something like:

    $options = new ChromeOptions();
    $capabilities = DesiredCapabilities::chrome();
    $capabilities->setCapability(ChromeOptions::CAPABILITY, $options);

    and DesiredCapabilities::chrome() function returns:

    return new static([
        WebDriverCapabilityType::BROWSER_NAME => WebDriverBrowserType::CHROME,
        WebDriverCapabilityType::PLATFORM => WebDriverPlatform::ANY,
    ]);

    -- where WebDriverCapabilityType::PLATFORM == platform.
    Replacing it with platformName in the WebDriverCapabilityType fixes the problem.

  2. added
    bug
    on Nov 14, 2019
  3. OndraM commented on Nov 14, 2019

    @OndraM
    Collaborator

    What version of browser, browser driver and selenium server do you use?

    I know why this is happening (the capabilities are indeed not yet W3C compatible), but I don't know why this is not happening to me and to tests on Travis 🤔.

  4. Lctrs commented on Nov 14, 2019

    @Lctrs
    ContributorAuthor

    Chrome 78.0.3904.97
    Chromedriver 78.0.3904.70

    Took from my travis job.

  5. OnkelTem commented on Nov 14, 2019

    @OnkelTem

    Chrome 77.0.3865.75
    ChromeDriver 77.0.3865.40

  6. OndraM commented on Nov 14, 2019

    @OndraM
    Collaborator

    Oh, I see. Well, we are apparently not sending platform requirements as part of capabilities in tests, while you are - is this correct?

  7. Lctrs commented on Nov 14, 2019

    @Lctrs
    ContributorAuthor

    I am calling the static factories Facebook\WebDriver\Remote\DesiredCapabilities::(chrome|firefox) at some point in my test.

  8. OndraM commented on Nov 14, 2019

    @OndraM
    Collaborator

    Right, so this is the issue, we add the incompatible platform ourselves 🙊
    https://github.com/facebook/php-webdriver/blob/ec7ce5b611e3a73eb789c783760487c89b4999a1/lib/Remote/DesiredCapabilities.php#L199

    It seems some kind of Capabilities conversion to W3C compatible ones will be needed in the end. I'm on it 🚀

  9. added 3 commits that reference this issue on Nov 14, 2019
    d906cf6
    cdef7d4
    a6cad80
  10. OndraM commented on Nov 14, 2019

    @OndraM
    Collaborator

    Ok, the implementation should be ready (see #678).

    Could you @Lctrs @OnkelTem please test your projects with branch w3c-capabilitites?

    composer require facebook/webdriver:dev-w3c-capabilitites@dev
    
  11. changed the title [-][1.8.0] Facebook\WebDriver\Exception\UnknownServerException: Illegal key values seen in w3c capabilities: [platform][/-] [+][1.8.0] Illegal key values seen in w3c capabilities: [platform][/+] on Nov 14, 2019
  12. Lctrs commented on Nov 14, 2019

    @Lctrs
    ContributorAuthor

    @OndraM here is the build : https://travis-ci.org/Lctrs/mink-panther-driver/builds/612038066 (ref PR : https://github.com/Lctrs/mink-panther-driver/pull/31). Much better. I would say that remaining errors are on my side. Good job !

    Also, would it be possible to provide a method somewhere that would tells us that the web driver is running in w3c mode ? Something like RemoteWebDriver::isW3cMode() : bool. That would helps users of the library to make the transition I think.

  13. OndraM commented on Nov 14, 2019

    @OndraM
    Collaborator

    Didn't check, but are you sure the errors are not related to W3C mode? There seems to be quite a lot of failed builds :).

    To see whether you are running W3C mode or not, you can use isW3cCompliant() method of RemoteWebDriver, which is already there.

  14. Lctrs commented on Nov 14, 2019

    @Lctrs
    ContributorAuthor

    At first glance, they seem to be related to things that has been removed in W3C mode. I'm also hitting a bug not related to W3C mode.

    Didn't known this one. Thanks :)

  15. OnkelTem commented on Nov 14, 2019

    @OnkelTem

    At first I thought it didn't work, due to this error message in my logs:

    unknown command: Cannot call non W3C standard command while in W3C mode
    

    But then I could nail down what raised this error:

    $this->driver->manage()->window()->maximize();
    

    If I comment this line out, my script does its job. It seems like I should have used some other command to maximize the window...

    This is my initialization part:

    function runBrowser($headless) {
        $options = new ChromeOptions();
        if ($headless) {
          $options->addArguments(['headless']);
        }
        $capabilities = DesiredCapabilities::chrome();
        $capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
        $this->driver = RemoteWebDriver::create(self::CONNECT_LINE, $capabilities);
        //$this->driver->manage()->window()->maximize();
    }
  16. OndraM commented on Nov 15, 2019

    @OndraM
    Collaborator

    @OnkelTem I added the missing W3C compatible maximize command (amongst few others) in #679 , so once this is merged, it should start working for you.

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

    bugw3c-protocol

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions