Skip to content

Commit 533584e

Browse files
Copilotkobenguyent
andauthored
Fix Puppeteer grabAttributeFrom returning a CSSStyleDeclaration for style (#5777)
* Initial plan * Apply remaining changes Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
1 parent c238bfe commit 533584e

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎lib/helper/Puppeteer.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2271,7 +2271,7 @@ class Puppeteer extends Helper {
22712271
const els = await this._locate(locator)
22722272
const array = []
22732273
for (let index = 0; index < els.length; index++) {
2274-
const a = await this._evaluateHandeInContext((el, attr) => el[attr] || el.getAttribute(attr), els[index], attr)
2274+
const a = await this._evaluateHandeInContext((el, attr) => (attr === 'style' ? el.getAttribute(attr) : el[attr] || el.getAttribute(attr)), els[index], attr)
22752275
array.push(a)
22762276
}
22772277
return array

‎test/helper/webapi.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,12 @@ export function tests() {
14691469
assert.equal(val, 'oldfag')
14701470
})
14711471

1472+
it('should grab full style attribute', async () => {
1473+
await I.amOnPage('/form/example1')
1474+
const style = await I.grabAttributeFrom('#LoginForm_username_em_', 'style')
1475+
assert.equal(style, 'display:none')
1476+
})
1477+
14721478
it('should grab attribute from element', async () => {
14731479
await I.amOnPage('/search')
14741480
const val = await I.grabAttributeFrom(

0 commit comments

Comments
 (0)