Clarification on Error response format in WebDriver spec

133 views
Skip to first unread message

Nick Abalov

unread,
Jul 31, 2015, 12:01:08 AM7/31/15
to Selenium Developers
In https://w3c.github.io/webdriver/webdriver-spec.html#handling-errors it is stated that in case of error HTTP response body should contain dictionary with error, message and stacktrace only:

{
  "error": "invalid session id",
  "message": "No active session with id 1234",
  "stacktrace": ""
}

In case of success commands should respond with:

{
  "status": "0",
  "value": *,
}

Yet, bindings expect error messages to contain "value" key set to error data.

Here is sample form C# bindings:

private static void UnpackAndThrowOnError(Response errorResponse)
        {
            // Check the status code of the error, and only handle if not success.
            if (errorResponse.Status != WebDriverResult.Success)
            {
                Dictionary<string, object> errorAsDictionary = errorResponse.Value as Dictionary<string, object>;

Python bindings expect "status" and "value" to be set


So could anybody clarify this situation:
1. Is it that bindings and driver implementations are currently lagging behind spec.
or
2. is it that error data dictionary (including message, error and stacktrace) should be packed into {"status": "*",  "value": *} response?
{
  "status": "0",
  "value": {
             "error": "invalid session id",
             "message": "No active session with id 1234",
             "stacktrace": ""
           }
}

David Burns

unread,
Jul 31, 2015, 2:01:03 AM7/31/15
to selenium-...@googlegroups.com

The bindings are lagging the specification. The python bindings are the closest following currently, the SHA in your link is not the latest released version, but far from complete.

I am working to get them closer to the specification currently as and when I have time.

David

--
You received this message because you are subscribed to the Google Groups "Selenium Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-developers/0ad63cec-3d94-46d1-8f14-9475a6f77376%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nick Abalov

unread,
Jul 31, 2015, 3:34:31 AM7/31/15
to Selenium Developers, david...@theautomatedtester.co.uk
So, what is best practice for WebDriver implementation at the moment?

Should we implement error responses as in W3C spec, or as it is supported by bindings and other drivers at the moment/

For example, here is a respnose from chromedriver:
{
    "name": "findElement",
    "sessionId": "93ed195d-5b3e-428c-81cd-5ecf3fa751a9",
    "status": 7,
    "value": {
        "message": "Unable to locate element: {\"method\":\"name\",\"selector\":\"zcasdasdasdasdasdq\"}",
        "stackTrace": [
            {
                "columnNumber": 26,
                "fileName": "file:///c:/users/nb5c6~1.aba/appdata/local/temp_~1/tmpwsbpyp/extensions/fxdr...@googlecode.com/components/driver-component.js",
                "lineNumber": 10271,
                "methodName": "FirefoxDriver.prototype.findElementInternal_"
            },
           ...
        ]
    }
}

or should we support both response formats by using new format, but keeping old keys (basically, mixing tow formats in one):
{
    "name": "findElement",
    "sessionId": "93ed195d-5b3e-428c-81cd-5ecf3fa751a9",
    "status": 7,
    "value": {
        "message": "Unable to locate element: {\"method\":\"name\",\"selector\":\"zcasdasdasdasdasdq\"}",
        "stackTrace": [
            {
                "columnNumber": 26,
                "fileName": "file:///c:/users/nb5c6~1.aba/appdata/local/temp_~1/tmpwsbpyp/extensions/fxdr...@googlecode.com/components/driver-component.js",
                "lineNumber": 10271,
                "methodName": "FirefoxDriver.prototype.findElementInternal_"
            },
           ...
        ]
    },
    "value": "Unable to locate element: {\"method\":\"name\",\"selector\":\"zcasdasdasdasdasdq\"}",
    "stackTrace": [...]
}

To unsubscribe from this group and stop receiving emails from it, send an email to selenium-developers+unsub...@googlegroups.com.

Nick Abalov

unread,
Jul 31, 2015, 3:47:14 AM7/31/15
to Selenium Developers, david...@theautomatedtester.co.uk, nick....@gmail.com
I meant 

...

        ]
    },
    "message": "Unable to locate element: {\"method\":\"name\",\"selector\":\"zcasdasdasdasdasdq\"}",
    "stackTrace": [...]
}



On Friday, July 31, 2015 at 1:34:31 PM UTC+6, Nick Abalov wrote:
So, what is best practice for WebDriver implementation at the moment?

Should we implement error responses as in W3C spec, or as it is supported by bindings and other drivers at the moment/

For example, here is a respnose from chromedriver:
{
    "name": "findElement",
    "sessionId": "93ed195d-5b3e-428c-81cd-5ecf3fa751a9",
    "status": 7,
    "value": {
        "message": "Unable to locate element: {\"method\":\"name\",\"selector\":\"zcasdasdasdasdasdq\"}",
        "stackTrace": [
            {
                "columnNumber": 26,
                "fileName": "file:///c:/users/nb5c6~1.aba/appdata/local/temp_~1/tmpwsbpyp/extensions/fxdriver@googlecode.com/components/driver-component.js",
                "lineNumber": 10271,
                "methodName": "FirefoxDriver.prototype.findElementInternal_"
            },
           ...
        ]
    }
}

or should we support both response formats by using new format, but keeping old keys (basically, mixing tow formats in one):
{
    "name": "findElement",
    "sessionId": "93ed195d-5b3e-428c-81cd-5ecf3fa751a9",
    "status": 7,
    "value": {
        "message": "Unable to locate element: {\"method\":\"name\",\"selector\":\"zcasdasdasdasdasdq\"}",
        "stackTrace": [
            {
                "columnNumber": 26,
                "fileName": "file:///c:/users/nb5c6~1.aba/appdata/local/temp_~1/tmpwsbpyp/extensions/fxdriver@googlecode.com/components/driver-component.js",

Jim Evans

unread,
Jul 31, 2015, 4:11:09 AM7/31/15
to Selenium Developers
Bottom line, at present, if you follow the spec, only Python will be able to talk to your implementation. That will change over time, of course, and hopefully soon, but that's the reality as of this moment. The worst possible approach, in my opinion, would be to try to munge the responses into some hybrid protocol. Either use the open source project's dialect of the wire protocol, or use the W3C spec's dialect. There are fundamental incompatibilities between the two if you try to mix them in the same session.

Andreas Tolfsen

unread,
Jul 31, 2015, 6:27:05 AM7/31/15
to selenium-...@googlegroups.com
On Fri, Jul 31, 2015 at 5:01 AM Nick Abalov <nick....@gmail.com> wrote:
In case of success commands should respond with:
{
  "status": "0",
  "value": *,
}
Success commands should, according to the specification, not contain a `status` field, and only in some cases `value`.

It is defined explicitly in each command’s remote end steps what the exact response body should look like.

1. Is it that bindings and driver implementations are currently lagging behind spec.
There are as far as I know no perfectly compliant local end implementations of the specification, except for one for Rust:

https://github.com/jgraham/webdriver-rust
Reply all
Reply to author
Forward
0 new messages