schickling/chromeless

Better error handling when error occurs in expressionResult

Open

#207 opened on Aug 9, 2017

View on GitHub
 (0 comments) (3 reactions) (0 assignees)TypeScript (13,240 stars) (606 forks)batch import
APIenhancementhelp wanted

Description

const { Chromeless } = require('chromeless')

async function run() {
  const chromeless = new Chromeless()

  const screenshot = await chromeless
    .goto('https://www.google.com')
    .click('.icon') //click
    .click('.passenger') //click
    .wait('#resultStats')
    .screenshot()

  console.log(screenshot) // prints local file path or S3 url

  await chromeless.end()
}
run().catch(console.error.bind(console))

the error message: Error: TypeError: Cannot read property 'click' of undefined at expressionResult (:8:17) at :10:11 at :16:7 at D:\git\headless\node_modules\chromeless\dist\src\util.js:302:31 at step (D:\git\headless\node_modules\chromeless\dist\src\util.js:40:23) at Object.next (D:\git\headless\node_modules\chromeless\dist\src\util.js:21:53) at fulfilled (D:\git\headless\node_modules\chromeless\dist\src\util.js:12:58 )

I could not know which click failed from the error message.

Contributor guide