question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] ElementHandle.getTagName()

See original GitHub issue

I’d like to retrieve the name of the tag from a playwright.ElementHandle, and it seems like this is not possible at the moment.

Something like

const $parent = await $el.$('xpath=..');
const tagName = await $parent.getTagName(); // <--

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
JoelEinbindercommented, Dec 29, 2020

our ElementHandle extend JSHandle, so you can do

const tagName = await $parent.evaluate(e => e.tagName);
// or
const tagName = await $parent.getProperty('tagName');
1reaction
tjenkinsoncommented, Jan 20, 2021

Yep that was me (https://github.com/microsoft/playwright/issues/4377)

I will need the the call to be isolated. Happy to try and open a PR for #4377 if someone could point me in the right direction, otherwise I’ll probably end up adding this in a fork because it looks simpler and using that for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

puppeteer howto get element tagName - Stack Overflow
It appears your elements is an array of ElementHandle s. ... jsonValue() ... const tagName = await page.evaluate( element => element.
Read more >
Element.tagName - Web APIs | MDN
The tagName read-only property of the Element interface returns the tag name of the element on which it's called.
Read more >
ElementHandle | Flood Element
Fetches the remote elements physical dimensions as width and height . Parameters. returns: Promise<Size>. tagName() #. Fetches the remote elements tagName ...
Read more >
Puppeteer - Getting Element Attribute - Tutorialspoint
We can get attribute values of an element using Puppeteer. The attributes are added within the HTML tag. They are used to describe...
Read more >
ElementHandle class - Puppeteer
If the given function returns a promise, then this method will wait till the promise resolves. $x(expression) · asElement() · boundingBox(), This method...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found