Closed Jiyr0119 closed 6 days ago
u can pass executable_path to chromium-based browser and maybe will be fixed
import asyncio
from playwright.async_api import async_playwright
from emunium import EmuniumPlaywright
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch(
executable_path=r'C:\Program Files\Google\Chrome\Application\chrome.exe',
headless=False
)
page = await browser.new_page()
emunium = EmuniumPlaywright(page)
await page.goto('https://duckduckgo.com/')
element = await page.wait_for_selector('[data-state="suggesting"]')
await emunium.type_at(element, 'Automating searches')
submit = await page.wait_for_selector('[aria-label="Search"]')
await emunium.click_at(submit)
await browser.close()
asyncio.run(main())
u can pass executable_path to chromium-based browser and maybe will be fixed
import asyncio from playwright.async_api import async_playwright from emunium import EmuniumPlaywright async def main(): async with async_playwright() as p: browser = await p.chromium.launch( executable_path=r'C:\Program Files\Google\Chrome\Application\chrome.exe', headless=False ) page = await browser.new_page() emunium = EmuniumPlaywright(page) await page.goto('https://duckduckgo.com/') element = await page.wait_for_selector('[data-state="suggesting"]') await emunium.type_at(element, 'Automating searches') submit = await page.wait_for_selector('[aria-label="Search"]') await emunium.click_at(submit) await browser.close() asyncio.run(main())
bro this demo I haven't tried it yet, but the other two have been changed to local paths, but they don't work on mac? Does this have anything to do with the computer system?
After I copied your code above, I ran the following error:
Traceback (most recent call last): File "/Users/jonathan/Downloads/mywork/emunium-demo/pldemo.py", line 25, in <module> asyncio.run(main()) File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 194, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/Users/jonathan/Downloads/mywork/emunium-demo/pldemo.py", line 18, in main await emunium.type_at(element, 'Automating searches') File "/Users/jonathan/Downloads/mywork/emunium-demo/venv/lib/python3.12/site-packages/emunium/browsers.py", line 123, in type_at center = await self.get_center(element) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jonathan/Downloads/mywork/emunium-demo/venv/lib/python3.12/site-packages/emunium/browsers.py", line 105, in get_center await self._get_browser_properties_if_not_found() File "/Users/jonathan/Downloads/mywork/emunium-demo/venv/lib/python3.12/site-packages/emunium/browsers.py", line 102, in _get_browser_properties_if_not_found await super()._get_browser_properties_if_not_found(screenshot_func) File "/Users/jonathan/Downloads/mywork/emunium-demo/venv/lib/python3.12/site-packages/emunium/base.py", line 70, in _get_browser_properties_if_not_found location = pyautogui.locateOnScreen(temp_screen_path, confidence=0.6) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jonathan/Downloads/mywork/emunium-demo/venv/lib/python3.12/site-packages/pyautogui/__init__.py", line 174, in wrapper raise ImageNotFoundException # Raise PyAutoGUI's ImageNotFoundException.
Because I am not a professional python developer, I use chatgpt to optimize code in my demo project. What I understand is that the error message is empty when printed。The latest code has been pushed to the demo warehouse. Thank you very much if you can help!!!
python version : 3.12 Minimal reproducible example :https://github.com/Jiyr0119/emunium-demo