Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parrallel execution[Question] #1605

Closed
tomern opened this issue Mar 31, 2020 · 3 comments
Closed

Parrallel execution[Question] #1605

tomern opened this issue Mar 31, 2020 · 3 comments

Comments

@tomern
Copy link

tomern commented Mar 31, 2020

Hi,
I would like to know how can you run playwright tests in parallel on same browser,
I know you can the following in order to run the same tests parallelly on different browsers.
Is there a test runner you can use in order to avoid using Promise.all method?

(async function() {
await Promise.all([
test(firefox),
test(chromium)
]);
})();

@arjunattam
Copy link
Contributor

Hi @tomern, you can use BrowserContexts to create parallelized executions in the same browser. See our core concepts guide that attempts to explain it. Let me know if need more details

@nrayburn-tech
Copy link

nrayburn-tech commented Apr 24, 2020

Also, #1736 has an example of doing it for multiple browsers as well.

Edit:
Sorry, I misread your question.
Here is an example doing it in a single browser.

import playwright from 'playwright';

(async () => {
  const browser = await playwright.chromium.launch({ headless: false });
  const context1 = await browser.newContext();
  const context2 = await browser.newContext();
  const page1 = await context1.newPage();
  const page2 = await context2.newPage();
  await page1.goto('https://google.com');
  await page2.goto('https://github.com');

  await page1.fill('input[title="Search"]', 'github.com');

  await context1.close();
  await context2.close();
  browser.close();
})();

@arjun27, the two examples in the docs/examples from your link do not show a way for multiple instances. I think it was just an incorrect link, the core-concepts does state that multiple contexts can be created. Either way, I think that multiple browsers and contexts testing is something that users will frequently question how to do. I think it may be worth creating an example for it.
If you agree, I can create an example and submit a PR for it.

@aslushnikov
Copy link
Collaborator

I would like to know how can you run playwright tests in parallel on same browser

@tomern For the original request here: we're getting ready to release our test runner (please follow #3552) which will support parallel test running and should cover all the needs there. Please keep an eye there!

I think it may be worth creating an example for it.

@nrayburn-tech so far it hasn't been brought many times, so I think the documentation is sufficient here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants