Get Element Tag Name

The Get Element Tag Name command of the WebDriver API returns the tag name of the referenced web element. If for example the element is an <img>, the returned tag name is "IMG", which is equivalent to calling Element.tagName on the element. For XML/XHTML documents it may be cased differently.

Syntax

Method URI template
GET /session/{session id}/element/{element id}/name

URL parameters

session id
Identifier of the session.
element id
Identifier of the web element to get the tag name of.

Errors

Session not created
Session does not exist.
No such window
The window object has been discarded, indicating that the tab or window has been closed.
Unexpected alert open
A user prompt, such as window.alert, blocks execution of command until it is dealt with.

Examples

Python:

from selenium import webdriver

session = webdriver.Firefox()
session.get("https://google.com/?hl=en")
search_box = driver.find_element_by_id("q")

print(search_box.tag_name)

Output:

INPUT

Specifications

Specification Status Comment
WebDriver
The definition of 'Get Element Tag Name' in that specification.
Living Standard Initial definition

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome No support No
Notes
No support No
Notes
Notes To enable Chromium support, include {"goog:chromeOptions": {"w3c": true}} in the capabilities.
Edge No support No
Notes
No support No
Notes
Notes The vendor-supported implementation for Edge is non-spec-conforming and incompatible.
Firefox Full support 55IE Full support 7Opera No support No
Notes
No support No
Notes
Notes To enable Chromium support, include {"goog:chromeOptions": {"w3c": true}} in the capabilities.
Safari No support No
Notes
No support No
Notes
Notes The vendor-supported implementation for Safari is non spec-conforming and incompatible.
WebView Android No support No
Notes
No support No
Notes
Notes To enable Chromium support, include {"goog:chromeOptions": {"w3c": true}} in the capabilities.
Chrome Android No support No
Notes
No support No
Notes
Notes To enable Chromium support, include {"goog:chromeOptions": {"w3c": true}} in the capabilities.
Edge Mobile No support No
Notes
No support No
Notes
Notes The vendor-supported implementation for Edge is non-spec-conforming and incompatible.
Firefox Android No support NoOpera Android No support No
Notes
No support No
Notes
Notes To enable Chromium support, include {"goog:chromeOptions": {"w3c": true}} in the capabilities.
Safari iOS No support No
Notes
No support No
Notes
Notes The vendor-supported implementation for Safari is non spec-conforming and incompatible.
Samsung Internet Android No support No
Notes
No support No
Notes
Notes The vendor-supported implementation for Samsung Internet is non-spec-conforming and incompatible.

Legend

Full support  
Full support
No support  
No support
See implementation notes.
See implementation notes.

Document Tags and Contributors

Contributors to this page: fscholz, ato
Last updated by: fscholz,