Skip to content

Threading in seleniumbase #2835

Answered by mdmintz
misterpeople asked this question in Q&A
Jun 5, 2024 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

Duplicate of #2828 (comment)

See the example that uses ThreadPoolExecutor with UC Mode:

import sys
from concurrent.futures import ThreadPoolExecutor
from seleniumbase import Driver
sys.argv.append("-n")  # Tell SeleniumBase to do thread-locking as needed

def launch_driver(url):
    driver = Driver(uc=True)
    try:
        driver.get(url=url)
        driver.sleep(2)
    finally:
        driver.quit()

urls = ['https://seleniumbase.io/demo_page' for i in range(3)]
with ThreadPoolExecutor(max_workers=len(urls)) as executor:
    for url in urls:
        executor.submit(launch_driver, url)

Or use pytest multithreading with pytest-xdist and the parameterized library: #2394 (comment)

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@misterpeople
Comment options

@mdmintz
Comment options

@misterpeople
Comment options

@mdmintz
Comment options

Answer selected by mdmintz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants