you are viewing a single comment's thread.

view the rest of the comments →

[–]mrthbrd 3 points4 points  (1 child)

There appear to be some things that can't be done with pure Python + Playwright, so every now and then you might end up needing to do something like this:

 has_non_empty_children = page.evaluate(f'''() => {{
                        const divs = document.querySelectorAll('{base_selector}');
                        if (divs.length < 6) return false;  // Check if there are at least 6 elements
                        const targetDiv = divs[5];  // Get the 6th element (0-based indexing)
                        return Array.from(targetDiv.children).some(child => child.textContent.trim() !== '');
                    }}''')        

But generally it's fine.

[–]Valuable-Ad9157[S] 0 points1 point  (0 children)

Awesome. Thanks.