joelgriffith / navalia

A bullet-proof, fast, and reliable headless browser API
https://joelgriffith.github.io/navalia/
GNU General Public License v3.0
957 stars 33 forks source link

Trying to grok 'Error: [object Object]' #66

Open rentallect opened 6 years ago

rentallect commented 6 years ago

I'm learning navalia, and have a test that looks on the page for a certain element, like this:

.then(() => chrome.exists('[#ns-leftdrawer-list-item--atlas]'))

it succeeds, and my test then attempts to click on a child element, like this:

chrome.click('[#ns-leftdrawer-list-item--atlas > a]')

this fails, and the chatter from navalia says this:

navalia:chrome :WARN > Retrying 1 time(s) due to issue: 'Error: [object Object]' +10ms

My question is: how do I get visibility into what the error actually is? Is there a way to dump/format the [object Object]?

joelgriffith commented 6 years ago

Yeah, it's likely that the error that's happening isn't being properly handled or printed by navalia. I'm recommending now that people take a look at other libraries like puppeteer or chromeless as those two have a lot more steam behind them. You can run your script with DEBUG=* node ... and navalia will print dump a lot more logs about what's going on.

Also: your exists/click references don't use the exact same selector.... which I'm not sure is intended or not. Just thought I'd post it out.

And finally, I've been working on a SaaS product that has a really nice debugger for figuring out why things like this happen. You can check it out at https://browserless.io/ and click the "try it out" button. Only caveat here is that the debugger only lets you use puppeteer, but the tooling for it is really really nice.

Failing all that, let me know and I can try and jump in and debug with you!