Full page reload after action seems to mess with the execution
Hello! I was running trying to run a small script based on your google's JSON search results example.
So my small change was using it to go to npmjs.com instead, and do a search for chromeless package, but when I execute this line, it returns a timeout error while waiting for '.search-results' element to pop up.
const { Chromeless } = require('chromeless');
async function run() {
const chromeless = new Chromeless()
const links = await chromeless
.goto('https://www.npmjs.com')
.type('chromeless', 'input[name="q"]')
.press(13)
.wait('.search-results')
.evaluate(() => {
// this will be executed in headless chrome
const links = [].map.call(
document.querySelectorAll('.search-results li'),
item => {
const { innerText: title, href } = item.querySelector('a.packageName');
return { title, href };
}
)
return JSON.stringify(links)
})
console.log(links)
await chromeless.end()
}
run().catch(console.error.bind(console))
Since that's the current behavior, I assume that chromeless works perfectly for SPAs but not so great for traditional full-page reload navigation style websites.
Is my assumption correct? If so, is there a workaround? If not and there's a step I'm missing, please lemme know.
Thanks!
In fact, just tried out the twitter example and it times out waiting for .status
Error: wait(".status") timed out after 10000ms
at Object.<anonymous> (/home/dprado/tmp/node_modules/chromeless/dist/src/util.js:84:60)
at step (/home/dprado/tmp/node_modules/chromeless/dist/src/util.js:40:23)
at Object.next (/home/dprado/tmp/node_modules/chromeless/dist/src/util.js:21:53)
at /home/dprado/tmp/node_modules/chromeless/dist/src/util.js:15:71
at __awaiter (/home/dprado/tmp/node_modules/chromeless/dist/src/util.js:11:12)
at Timeout.<anonymous> (/home/dprado/tmp/node_modules/chromeless/dist/src/util.js:77:81)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5)
Hi, I'm having the same issue. Is there any solution for this?
So, right now I'm using chromedriver with webdriverio for now, just because I need to run my stuff quickly. Hopefully this can be fixed at some point, it's an awesome project!
This is happening for me also:
const { Chromeless } = require('chromeless')
async function run() {
const chromeless = new Chromeless()
const cookies = await chromeless
.goto('https://www.clickpos.net/login/')
.type('TLSMG', 'input[name="txtLoginCode"]')
.screenshot()
console.log(cookies) // prints local file path or S3 url
await chromeless.end()
}
run().catch(console.error.bind(console))
results in
Error: wait("input[name="txtLoginCode"]") timed out after 10000ms
at Object.<anonymous> (/Users/luke/Code/Playground/lucasts-agent/node_modules/chromeless/dist/src/util.js:137:60)
at step (/Users/luke/Code/Playground/lucasts-agent/node_modules/chromeless/dist/src/util.js:40:23)
Does that element exist on the page? That error seems to indicate so (but might genuinely be there). Just a thought!
It looks like the error only occurs in canary headless mode, it works correctly if the canary window is up.
This is the page in question: https://www.clickpos.net/login/
Could the page's js be erroring out in headless mode?
Looks like that you were right, getting a page with an error when requesting the above url in headless mode. I took a screenshot: https://jumpshare.com/v/b9D4Rhvx6qBHwDbUr6XK
Not sure how to go above debugging the page and figuring out why it causes an error in headless mode.
+1 is this expected behavior? click() 'ing on links will not follow them..? I'm scratching my head here.