Closed
Description
i want to open 2 pages and create 2 thread,thread 1 process page1,and thread 2 process page 2.
i try this code
def run1(context):
page = context.new_page()
page.goto('https://page1')
page.wait_for_timeout(5000)
page.close()
def run2(context):
page = context.new_page()
page.goto('https://page2')
page.wait_for_timeout(1000)
page.close()
def main():
with sync_playwright() as playwright:
browser = playwright.chromium.launch(headless=False)
context = browser.new_context()
t=Thread(target=run1,args=(context,))
t1=Thread(target=run2,args=(context,))
t.start()
t1.start()
t.join()
t1.join()
context.close()
browser.close()
but first open page 1 and 5 seconds later ,it opens page 2.
it oepens the pages one by one
how can i process multi page in diffrent thread at same time