Skip to content

Commit

Permalink
Fix getSize if prop is 0 (#8136)
Browse files Browse the repository at this point in the history
* fix getSize if prop is 0

* fix test
  • Loading branch information
christian-bromann committed Mar 21, 2022
1 parent d9ef72f commit d77a890
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/webdriverio/src/commands/element/getSize.ts
Expand Up @@ -47,7 +47,7 @@ async function getSize (
rect = await this.getElementSize(this.elementId) as RectReturn
}

if (prop && rect[prop]) {
if (prop && typeof rect[prop] === 'number') {
return rect[prop] as number
}

Expand Down
2 changes: 2 additions & 0 deletions packages/webdriverio/tests/commands/element/getSize.test.ts
Expand Up @@ -54,6 +54,8 @@ describe('getSize test', () => {
expect(width).toBe(50)
const height = await elem.getSize('height')
expect(height).toBe(30)
const invalid = await elem.getSize('foobar')
expect(invalid).toEqual({ width: 50, height: 30 })
})

afterEach(() => {
Expand Down

0 comments on commit d77a890

Please sign in to comment.