Skip to content

Commit

Permalink
v2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
DedInc committed Jun 8, 2024
1 parent ddcc67b commit 51a1581
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 6 deletions.
Binary file added emunium/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added emunium/__pycache__/base.cpython-310.pyc
Binary file not shown.
Binary file added emunium/__pycache__/browsers.cpython-310.pyc
Binary file not shown.
Binary file added emunium/__pycache__/standalone.cpython-310.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion emunium/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ async def _get_browser_properties_if_not_found(self, screenshot_func):
await screenshot_func(temp_screen_path)
else:
screenshot_func(temp_screen_path)
location = pyautogui.locateOnScreen(temp_screen_path, confidence=0.8)

location = pyautogui.locateOnScreen(temp_screen_path, confidence=0.6)
self.browser_offsets = (
location.left,
location.top,
Expand Down
15 changes: 11 additions & 4 deletions emunium/browsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async def type_at(self, element, text, characters_per_minute=280, offset=20, cli
center = await self.get_center(element)
self._move(center)
self._click(click_type)
await self.silent_type(text, characters_per_minute, offset)
self.silent_type(text, characters_per_minute, offset)

async def scroll_to(self, element):
await self._get_browser_properties_if_not_found()
Expand All @@ -91,7 +91,14 @@ def __init__(self, page):

async def _get_browser_properties_if_not_found(self):
async def screenshot_func(path):
await self.page.screenshot(path=path)
viewport_size = self.page.viewport_size
clip = {
'x': 0,
'y': 0,
'width': viewport_size['width'] // 2,
'height': viewport_size['height'] // 2
}
await self.page.screenshot(path=path, clip=clip)
await super()._get_browser_properties_if_not_found(screenshot_func)

async def get_center(self, element):
Expand All @@ -116,7 +123,7 @@ async def type_at(self, element, text, characters_per_minute=280, offset=20, cli
center = await self.get_center(element)
self._move(center)
self._click(click_type)
await self.silent_type(text, characters_per_minute, offset)
self.silent_type(text, characters_per_minute, offset)

async def scroll_to(self, element):
await self._get_browser_properties_if_not_found()
Expand All @@ -125,4 +132,4 @@ async def scroll_to(self, element):
if element_rect is None:
return None

self._scroll_smoothly_to_element(element_rect)
self._scroll_smoothly_to_element(element_rect)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='emunium',
version='2.0.1',
version='2.0.2',
author='Maehdakvan',
author_email='visitanimation@google.com',
description='A Python module for automating interactions to mimic human behavior in standalone apps or browsers when using Selenium, Pyppeteer, or Playwright.',
Expand Down

0 comments on commit 51a1581

Please sign in to comment.