Skip to content

Commit

Permalink
Improve wdio logging on browser/element objects (#9664)
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Jan 23, 2023
1 parent 17e7fdc commit 8f5cc7e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/wdio-utils/src/monad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,15 @@ export default function WebDriver (options: Record<string, any>, modifier?: Func
/**
* always transform result into promise
*/
Promise.resolve(result).then((res) => {
log.info('RESULT', res)
Promise.resolve(result).then((res: unknown) => {
let resultLog = res
if (res instanceof SCOPE_TYPES.element) {
resultLog = `WebdriverIO.Element<${(res as { elementId: string }).elementId}>`
} else if (res instanceof SCOPE_TYPES.browser) {
resultLog = 'WebdriverIO.Browser'
}

log.info('RESULT', resultLog)
this.emit('result', { name, result: res })
}).catch(() => {})

Expand Down

0 comments on commit 8f5cc7e

Please sign in to comment.