Skip to content

Fix Puppeteer grabAttributeFrom returning a CSSStyleDeclaration for style - #5777

Open
kobenguyent with Copilot wants to merge 2 commits into
4.xfrom
copilot/fix-grab-attribute-from
Open

kobenguyent with Copilot wants to merge 2 commits into
4.xfrom
copilot/fix-grab-attribute-from

Conversation

Copilot AI commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

In Puppeteer, grabAttributeFrom(locator, 'style') returned a partial object like { '0': 'transform' } instead of the attribute string. grabAttributeFromAll read el[attr] before falling back to getAttribute, and for style that property is a CSSStyleDeclaration, not the attribute text.

Changes

  • lib/helper/Puppeteer.js: grabAttributeFromAll now uses getAttribute for style. All other attributes keep the existing property-first lookup, so checked, value and similar still return their DOM property values.
  • test/helper/webapi.js: added a shared test that reads the style attribute of an element with an inline style and expects the full string.
// <div style="transform: translateX(-200%);">
await I.grabAttributeFrom('div', 'style')
// before: { '0': 'transform' }
// after:  'transform: translateX(-200%);'

Playwright, WebDriver and CDPBrowser call getAttribute directly and are unaffected.

Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix grabAttributeFrom to return complete element attribute Fix Puppeteer grabAttributeFrom returning a CSSStyleDeclaration for style Oct 31, 2026
Copilot AI requested a review from kobenguyent October 31, 2026 06:19
@kobenguyent
kobenguyent marked this pull request as ready for review October 31, 2026 06:20

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

grabAttributeFrom returns just a part of element attribute

2 participants