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

[Nodriver] find_all bug #2014

Open
boludoz opened this issue Sep 11, 2024 · 2 comments
Open

[Nodriver] find_all bug #2014

boludoz opened this issue Sep 11, 2024 · 2 comments

Comments

@boludoz
Copy link

boludoz commented Sep 11, 2024

original

    async def find_all(
        self,
        text: str,
        timeout: Union[int, float] = 10,
    ) -> List[nodriver.Element]:
        """
        find multiple elements by text
        can also be used to wait for such element to appear.

        :param text: text to search for. note: script contents are also considered text
        :type text: str

        :param timeout: raise timeout exception when after this many seconds nothing is found.
        :type timeout: float,int
        """
        loop = asyncio.get_running_loop()
        now = loop.time()

        text = text.strip()
        items = await self.find_elements_by_text(text)

        while not items:
            await self
            results = await self.find_elements_by_text(text)
            if loop.time() - now > timeout:
                raise asyncio.TimeoutError(
                    "time ran out while waiting for text: %s" % text
                )
            await self.sleep(0.5)
        return items

fixed:

    async def find_all(
        self,
        text: str,
        timeout: Union[int, float] = 10,
    ) -> List[nodriver.Element]:
        """
        find multiple elements by text
        can also be used to wait for such element to appear.

        :param text: text to search for. note: script contents are also considered text
        :type text: str

        :param timeout: raise timeout exception when after this many seconds nothing is found.
        :type timeout: float,int
        """
        loop = asyncio.get_running_loop()
        now = loop.time()

        text = text.strip()
        items = await self.find_elements_by_text(text)

        while not items:
            await self
            items = await self.find_elements_by_text(text)
            if loop.time() - now > timeout:
                raise asyncio.TimeoutError(
                    "time ran out while waiting for text: %s" % text
                )
            await self.sleep(0.5)
        return items
@boludoz
Copy link
Author

boludoz commented Sep 11, 2024

the original func have 'resuts =' instead items

@stephanlensky
Copy link

@boludoz, commented on a couple of your issues already but this too is fixed in my fork: https://github.com/stephanlensky/zendriver

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

2 participants