kaliiiiiiiiii / Selenium-Driverless

undetected Selenium without usage of chromedriver
https://kaliiiiiiiiii.github.io/Selenium-Driverless/
Other
430 stars 52 forks source link

add option start_session #187

Closed milahu closed 4 months ago

milahu commented 4 months ago

allow to defer the actual start of chromium

the context manager webdriver.Chrome is useful to ensure cleanup but it can be too limiting when the app later decides that it does not need chromium

async def main():

    chrome_options = webdriver.ChromeOptions()

    args = dict(
        options=chrome_options,
        start_session=False,
    )

    async with webdriver.Chrome(**args) as driver:

        actually_need_chromium = False
        if not actually_need_chromium:
            return

        # actually start chromium
        await driver.start_session()

        await driver.get('http://nowsecure.nl#relax')
kaliiiiiiiiii commented 4 months ago

but why'd someone want that for lol?

Why not use the following?

async def main():

    chrome_options = webdriver.ChromeOptions()

    args = dict(
        options=chrome_options,
    )

    actually_need_chromium = False
    if not actually_need_chromium:
        return

    async with webdriver.Chrome(**args) as driver:
        await driver.get('http://nowsecure.nl#relax')
milahu commented 4 months ago

yepp, nevermind

i had the wrong impression that some other selenium library requires explicit driver.start_session() which gives me more freedom in the sequence of commands

but no...

kaliiiiiiiiii commented 4 months ago

haha well then nvm:)