-
Notifications
You must be signed in to change notification settings - Fork 573
Parallel execution #88
Comments
I think this is a great idea, currently I am pulling a lot of data in parallel by running multiple terminals executing |
This seems to work if multiple instances of |
Does it work with multiple instances of 'Chromeles' and one instance of Chrome on AWS ? |
I don't know about AWS, but it works on my local machine with multiple chromeless instances and one chrome headless running. |
@LeMoussel yes. |
So would it work if I use chromeless from a NodeJS server that handles requests from several users? |
Each instance of I wrote some more in #24 (comment) about running multiple Chromeless instances at once. |
Is it possible to run parallel tests locally? I have an example based on #24 (comment) which does the following:
I am hoping the 3 windows that I get do not share session. That will allow me to write atomic tests. I am on Chrome Canary 62.0.3182.0 (64-bit) |
@sul4bh make sure each instance has it's own debugger port with Typically Chrome doesn't like to run more than one instance of itself. To run multiple, separate instances of Chrome locally, you might need to run each within a Docker container. From our work-in-progress CircleCI config: docker run \
-d \
--rm \
--name chrome \
--shm-size 1024m \
-p 9222:9222 \
--cap-add SYS_ADMIN \
yukinying/chrome-headless-browser |
@adieuadieu I was thinking, we can add an option key to |
@sul4bh instead of open in a random port, what do you think about allow to pass port into constructor? |
@sul4bh I think that you'll need to open an instance on a different port |
@sul4bh Hm.. Internally, @ricardovsilva while admittedly not well documented, it's possible to specify a port in the Chromeless constructor: const chromeless = new Chromeless({ cdp: { port: 1234 } } }) More options in code here. |
@adieuadieu works like a charm, that's allow me to run tests in parallel and specify a port range for each chrome that opens. |
@adieuadieu I created a PR #271 to update docs with port option. |
@adieuadieu about open chrome with a random port, I think that is a bad idea because chromeless doesn't have any control about which ports are available, and it can leads to strange behaviours. |
@adieuadieu Thanks for the pointer to I am working on a PR to add the random port feature. Having that will allow us to run the tests in parallel using local Chrome instances. |
I can't seem to get this working when running locally. I just get 10 Chrome icons pop up, but the pages never load: const Chromeless = require('chromeless').default var list = ['http://www.google.com','http://www.google.com','http://www.google.com','http://www.google.com','http://www.google.com','http://www.google.com','http://www.google.com','http://www.google.com','http://www.google.com'] async function run(url)
} async function test() test().catch(console.error.bind(console)) Any ideas? |
@adieuadieu I got that working locally - thanks for sharing. Having trouble running more than once though. I start up the container, run my process, it executes fine, then I disconnect. When trying to run an additional process against the container, it seems that it just stalls. Looking at the container, it looks like it is still running the previous site from the first call. Have you run into this? |
I wound up accomplishing this with the following: const { Chromeless } = require('chromeless')
function sleep() {
return new Promise(resolve => {
setTimeout(resolve, 2000)
})
}
const sites = [
'https://google.com',
'https://apple.com',
'https://reddit.com',
'https://twitter.com',
'https://facebook.com'
]
async function run() {
try {
const masterChromeless = new Chromeless()
await sleep() // Needed to wait for Chrome to start up
const promises = sites.map(site => {
return new Promise((resolve, reject) => {
const chromeless = new Chromeless({ launchChrome: false })
chromeless
.goto(site)
.screenshot()
.then(async screenshot => {
await chromeless.end()
resolve(screenshot)
})
.catch(err => reject(err))
})
})
const screenshots = await Promise.all(promises)
screenshots.forEach(screenshot => console.log(screenshot))
await masterChromeless.end()
} catch (err) {
console.error(err)
}
}
run() This will spawn one Chrome instance and then launch a tab for each site. Ideally |
@eddiezane this isn't exactly parallel right? It does open up multiple browser tabs but the sequence of the actions are round robin. It doesn't take screenshots all at the same time, and i can see each browser tab closes one at a time. I'm looking for something that exactly does everything at the same time so i can simulate 10's of simultaneous user activities at a site. |
@mickeyren trying to do the same as you "run 1000's of tests at the same time" via lambda. I want these to be different instances of chrome (not different tabs). Wouldn't the above example work? The local code would be waiting for the lambda to respond? I find it a little wierd that their isn't an example of this when the headline feature of chromeless is this parallel running of tests. |
What would be a proof of concept for executing an array of chromeless "agents" in parallel?
ie (currently)
Current Theory
Promise.all(arrayOfAgents).then(result => ...)
However, it returns an array of
undefined
.The text was updated successfully, but these errors were encountered: