ultrafunkamsterdam / undetected-chromedriver

Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
https://github.com/UltrafunkAmsterdam/undetected-chromedriver
GNU General Public License v3.0
9.99k stars 1.16k forks source link

[NODRIVER] set_all bug, The cookies argument will never be used. #2020

Open boludoz opened 2 months ago

boludoz commented 2 months ago
    async def set_all(self, cookies: List[cdp.network.CookieParam]):
        """
        set cookies

        :param cookies: list of cookies
        :type cookies:
        :return:
        :rtype:
        """
        connection = None
        for tab in self._browser.tabs:
            if tab.closed:
                continue
            connection = tab
            break
        else:
            connection = self._browser.connection
        cookies = await connection.send(cdp.storage.get_cookies())
        await connection.send(cdp.storage.set_cookies(cookies))

Must be:

    async def set_all(self, cookies: List[cdp.network.CookieParam]):
        """
        set cookies

        :param cookies: list of cookies
        :type cookies:
        :return:
        :rtype:
        """
        connection = None
        for tab in self._browser.tabs:
            if tab.closed:
                continue
            connection = tab
            break
        else:
            connection = self._browser.connection
        await connection.send(cdp.storage.set_cookies(cookies))

This line must be deleted: cookies = await connection.send(cdp.storage.get_cookies())

ultrafunkamsterdam commented 2 months ago

You are somewhat right. The implementation was different but I'm afraid something reverted it then. The original implementation does fetch the current cookies, but merges them before inserting . Will have a look at it when there's time

boludoz commented 2 months ago

You are somewhat right. The implementation was different but I'm afraid something reverted it then. The original implementation does fetch the current cookies, but merges them before inserting . Will have a look at it when there's time

The existing ones are automatically replaced and there is no need to do so, I have already tested it.

boludoz commented 2 months ago

image anda bug here

boludoz commented 2 months ago

I've reported several bugs and they weren't fixed, I guess every big project needs more than one person on it and you're overwhelmed. Do you mind if I fork it and make some improvements, especially a special function to save iframes as tabs?

boludoz commented 2 months ago

Another thing I would like is to be able to avoid excessive use of awaits like:

await page.find( '//*[@id="loginEmail"]', timeout=10).click() instead:

await (await page.find( '//*[@id="loginEmail"]', timeout=10)).click()

There are some pages that refresh and that would be very useful. The way you used the CDP library is why I will always support this project.

And another one that would help reduce the code required to complete a project is to add boolean functions like if is_found, is_found_and_visible.

stephanlensky commented 2 weeks ago

Hey @boludoz , I just commented on your other issue https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/2013, but I've also included this fix in my fork: https://github.com/stephanlensky/zendriver