DedInc / emunium

A Python module for automating interactions to mimic human behavior in standalone apps or browsers when using Selenium, Pyppeteer, or Playwright. Provides utilities to programmatically move the mouse cursor, click on page elements, type text, and scroll as if performed by a human user.
https://pypi.org/project/emunium/
MIT License
38 stars 4 forks source link

I tried script and it doesnt work #6

Closed deschandhok24 closed 2 months ago

deschandhok24 commented 3 months ago

I tried the script for playwright and selenium in the examples you show and it doesnt work. It goes to wrong element or raises ImageNotFoundException due to confidence being to low.

nnishad commented 3 months ago

`async def _get_browser_properties_if_not_found(self, screenshot_func): if not self.browser_offsets or not self.browser_inner_window: with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as temp_file: temp_screen_path = temp_file.name if asyncio.iscoroutinefunction(screenshot_func): await screenshot_func(temp_screen_path) else: screenshot_func(temp_screen_path)

        location = pyautogui.locateOnScreen(temp_screen_path, confidence=0.0)
        self.browser_offsets = (
            location.left,
            location.top,
        )
        self.browser_inner_window = get_image_size(temp_screen_path)
        os.remove(temp_screen_path)`

Make confidence to 0.0 . This is a hack. not sure what exactly this screenshot is required for apart from screensize. Developer has used very clever way of getting offset of browser.