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.

elementHandle.getProperties() returns an empty map - which i think is a bug

See original GitHub issue

For the following html…

<form class="" action="index.html" method="post">
  <input type="text" name="some name" placeholder="some placeholder" value="">
</form>

Im trying to extract the properties like so:

const formHandle = await page.$('form')
const inputs = await formHandle.$$('input')
const properties = await inputs[0].getProperties()

The relevant documentation is here: elementHandle.getProperties() My inputs[0] is indeed an elementHandle, since it comes form the formHandle as shwon here: elementHandle.$()

But why is the properties map empty then? Given that html form is supposed to contain : name, type, placeholder and value

If i use await inputs[0].getProperty("placeholder") then it works as expected.

Does this mean that the elementHandle.getProperties() function is not actually working?!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:10
  • Comments:5

github_iconTop GitHub Comments

7reactions
jnd0commented, May 8, 2020

Having the same issue here.

For example when trying to extract an XPath from information link the following works just fine:

        const [xpathResult] =  await this.page.$x(xpath);
   
        const link = await xpathResult.getProperty('href');

        console.log(await link.jsonValue());

However when trying to get all the properties:

        const [xpathResult] =  await this.page.$x(xpath);

        const link = await xpathResult.getProperties();
    
        console.log(await link.get('href'));

Here link returns an empty map Map(0) {}and so I can’t get the href property.

I need a way to get all the properties from element handler as an object but I couldn’t find any other way to do that other than getProperties

0reactions
shtse8commented, Aug 17, 2022

I have the same issue. How can I get all properties of element?

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's the expected behavior of puppeteer's ElementHandle ...
It looks like puppeteer's getProperty() actually tries to parse the style in some way, which parsing is buggy/incomplete. The only way to get ......
Read more >
webdriverio/webdriverio - Gitter
let's start by removing the empty browser.pause(); ... I think there might be a mistake somewhere in the testcode or it might be...
Read more >
puppeteer document is not defined - You.com | The AI Search ...
I think document would only be available within page.evaluate (according to puppeteer ... const isDone = await this.page.evaluate(`(async() => { return new ...
Read more >
mozilla-central: changeset 488667 ...
getIntPref( "devtools.netmonitor.panes-search-height" ); + return ... IsComplete(), + "Sheet thinks it's not complete while we think it is") ...
Read more >
Remove Hibernate from Project due to GPL license - Apache
Moved an icon from the Hibernate Module to the j2ee.persistence module as its used for the mapping file icon.
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