Skip to main content

getTagName

Overview

Use the getTagName command to get the tag name of a DOM element.

Usage

await browser.$(selector).getTagName();

Usage Examples

index.html

<div id="elem">Lorem ipsum</div>

getTagName.js

it("should demonstrate the getTagName command", async ({ browser }) => {
const tagName = await browser.$("#elem").getTagName();

console.log(tagName); // outputs: "div"
});

References

We'd like to give credit to the original WebdriverIO docs article, from which we drew some information while writing our version.