Skip to content

Latest commit

 

History

History
225 lines (183 loc) · 7.08 KB

element-inspection.md

File metadata and controls

225 lines (183 loc) · 7.08 KB
ms.assetid description title author ms.author ms.date ms.topic ms.prod keywords
2274c96f-0e32-4ebb-9294-865ddf00c45c
Learn useful information about the commands used for inspecting elements for the WebDriver API.
Webdriver commands - Element inspection
erikadoyle
edoyle
02/08/2017
article
microsoft-edge
edge, web development, html, css, javascript, developer

Element Inspection Commands

Microsoft Edge supports the following WebDriver commands for inspecting elements:

HTTP Request Commands
/session/{sessionId}/element Find Element, Find Elements
/session/{sessionId}/element/{id}/attribute/{name} Get Element Attribute
/session/{sessionId}/element/{id}/css/{propertyName} Get CSS Value
/session/{sessionId}/element/{id}/displayed Is Element Displayed
/session/{sessionId}/element/{id}/enabled Is Element Enabled
/session/{sessionId}/element/{id}/name Get Element Tag Name
/session/{sessionId}/element/{id}/selected Is Element Selected
/session/{sessionId}/element/{id}/text Get Element Text

Find Element

Name Find Element
Description Searches for a given element on the page, starting from the document root.
Spec W3C WebDriver, JSON Wire Protocol
HTTP Request POST /session/{sessionId}/element

JSON Parameters

{
    "using": "id",
    "value": "clickAnchorElement"
}

JSON Response Value

{
    "sessionId": "{sessionId}",
    "status": 0,
    "value": {
        "ELEMENT": "{elementId}",
        "element-6066-11e4-a52e-4f735466cecf": "{elementId}"
    }
}

Find Elements

Name Find Elements
Description Searches for all elements on the page with a given attribute value, starting from the document root.
Spec W3C WebDriver, JSON Wire Protocol
HTTP Request POST /session/{sessionId}/elements

JSON Parameters

{
    "using": "id",
    "value": "clickAnchorElement"
}

JSON Response Value

{
    "sessionId": "{sessionId}",
    "status": 0,
    "value": {
        "ELEMENT": "{elementId}",
        "element-6066-11e4-a52e-4f735466cecf": "{elementId}"
    }
}

Get Element Attribute

Name Get Element Attribute
Description Gets the value of the specified element's specified attribute.
Spec W3C WebDriver, JSON Wire Protocol
HTTP Request GET /session/{sessionId}/element/{elementId}/attribute/{name}

JSON Parameters None.

JSON Response Value

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

Get CSS Value

Name Get CSS Value
Description Queries the computed value of the specified element's specified CSS property.
Spec W3C WebDriver, JSON Wire Protocol
HTTP Request GET /session/{sessionId}/element/{elementId}/{propertyName}

JSON Parameters None.

JSON Response Value

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

Is Element Displayed

Name Is Element Displayed
Description Determines if an element is currently displayed.
Spec W3C WebDriver, JSON Wire Protocol
HTTP Request GET /session/{sessionId}/element/{elementId}/displayed

JSON Parameters None.

JSON Response Value

{
    "sessionId": "{sessionId}",
    "status": 0,
    "value": {bool}

}

Is Element Enabled

Name Is Element Enabled
Description Determines if an element is currently enabled.
Spec W3C WebDriver, JSON Wire Protocol
HTTP Request GET /session/{sessionId}/element/{elementId}/name

JSON Parameters None.

JSON Response Value

{
    "sessionId": "{sessionId}",
    "status": 0,
    "value": {bool}
}

Get Element Tag Name

Name Get Element Text
Description Retrieves the specified element's tag name.
Spec W3C WebDriver, JSON Wire Protocol
HTTP Request GET /session/{sessionId}/element/{elementId}/name

JSON Parameters None.

JSON Response Value

{
    "sessionId": "{sessionId}",
    "status": 0,
    "value": "{tagName}"
}

Is Element Selected

Name Is Element Selected
Description Determines if an OPTION element, or an INPUT element of type checkbox or radiobutton is currently selected.
Spec W3C WebDriver, JSON Wire Protocol
HTTP Request GET /session/{sessionId}/element/{elementId}/selected

JSON Parameters None.

JSON Response Value

{
    "sessionId": "{sessionId}",
    "status": 0,
    "value": {bool}

}

Get Element Text

Name Get Element Text
Description Returns the visible text for the element.
Spec W3C WebDriver, JSON Wire Protocol
HTTP Request GET /session/{sessionId}/element/{elementId}/text

JSON Parameters None.

JSON Response Value

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