This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 28754 - In section 11, it is not clear when to return no such element error
Summary: In section 11, it is not clear when to return no such element error
Status: RESOLVED FIXED
Alias: None
Product: Browser Test/Tools WG
Classification: Unclassified
Component: WebDriver (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Browser Testing and Tools WG
QA Contact: Browser Testing and Tools WG
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 20860
  Show dependency treegraph
 
Reported: 2015-06-04 16:18 UTC by John Jansen
Modified: 2015-10-26 05:40 UTC (History)
3 users (show)

See Also:


Attachments

Description John Jansen 2015-06-04 16:18:45 UTC
"Return a no such element error."

I believe this is just missing an 'else' but didn't want to make that change myself.

CURRENT:

To get a known web element with a UUID reference:

For each web element in the current browsing context’s set of known web elements:

If web element’s web element reference matches reference, return web element.
Return a no such element error.

PROPOSED:

To get a known web element with a UUID reference:

For each web element in the current browsing context’s set of known web elements:

If web element’s web element reference matches reference, return web element.
Else, return a no such element error.
Comment 1 James Graham 2015-06-04 16:25:47 UTC
I think this is just an early return. I agree it might be clearer without (I think it would be much much better to use the success/error machinery here, as in:

To get a known web element with a UUID reference:

If there is an element in the browsing current context's set of known elements whose web element reference is reference, return success with data element.

Otherwise, return error with status no such element.
Comment 2 James Graham 2015-06-04 16:37:34 UTC
Oh, ato pointed out that this text is the subject of PR #76 anyway.
Comment 3 Andreas Tolfsen 2015-06-04 17:12:39 UTC
This is just an early return, in pseudo code:

    for el of els {
        if el == expected {
            return el
        }
    }
    return error

That is a simplistic version of how I would implement it.  In reality I would use a more performant search algorithm.  What we’re trying to say is that “find the entry on list that matches this other element I have”.

I find it weird to use an else clause because I’ve never encountered a for loop construct that has one.

I should also add that there’s an open PR to improve the web element lookup: https://github.com/w3c/webdriver/pull/76