daijro / camoufox

🦊 Undetected web scraping browser
Mozilla Public License 2.0
55 stars 5 forks source link

Playwright locator.bounding_box() always times out #6

Closed netdev1 closed 1 week ago

netdev1 commented 2 weeks ago

calls to locator.bounding_box(), locator.screenshot(), locator.evaluate() always time out even though the html element exists & is visible. Other locator methods like locator.text_content(), locator.is_visible(), locator.click() work as expected. Simple proof of concept below:

import asyncio
import json
from playwright.async_api import async_playwright

# Example config
CONFIG = {
 'window.outerHeight': 1056,
 'window.outerWidth': 1920,
 'window.innerHeight': 1008,
 'window.innerWidth': 1920,
}

async def main():
    async with async_playwright() as p:
        # Create a Firefox instance to the launcher
        browser = await p.firefox.launch(
            # Pass in the Camoufox launcher and config JSON
            executable_path='/path/to/camoufox/launch',
            args=['--config', json.dumps(CONFIG)],
            # Launch in headful mode
            headless=False
        )
        # Continue as normal
        page = await browser.new_page()
        await page.goto('https://example.com')
        await asyncio.sleep(3)
        locator = page.locator("xpath=//h1")
        l1 = locator.first
        print(await l1.count())
        print(await l1.text_content())
        print(await l1.bounding_box())
        await asyncio.sleep(3)
        await browser.close()

if __name__ == "__main__":
    asyncio.run(main())
daijro commented 1 week ago

Fixed in v130.0-beta.5