Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pydoll/elements/web_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ async def click(
logger.info(
f'Clicking element (humanized): x={position_to_click[0]}, y={position_to_click[1]}'
)
await self._mouse.click(position_to_click[0], position_to_click[1])
await self._mouse.click(position_to_click[0], position_to_click[1], humanize=True)
return

logger.info(
Expand Down
9 changes: 7 additions & 2 deletions tests/test_connection_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,13 @@ async def test__incoming_messages(connection_handler):
connection_handler._ws_connection.recv = AsyncMock(
return_value='{"id": 1, "method": "SomeMethod"}'
)
async_generator = connection_handler._incoming_messages()
result = await anext(async_generator)

try:
async_generator = connection_handler._incoming_messages()
result = await anext(async_generator)
finally:
await async_generator.aclose()

assert result == '{"id": 1, "method": "SomeMethod"}'


Expand Down
20 changes: 10 additions & 10 deletions tests/test_web_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from unittest.mock import AsyncMock, patch

import pytest
import pytest_asyncio

from pydoll.browser.options import ChromiumOptions as Options
from pydoll.browser.chromium.chrome import Chrome
Expand All @@ -22,8 +21,8 @@
from pydoll.protocol.runtime.types import CallArgument


@pytest_asyncio.fixture
async def mock_connection_handler():
@pytest.fixture
def mock_connection_handler():
"""Mock connection handler for WebElement tests."""
with patch('pydoll.connection.ConnectionHandler', autospec=True) as mock:
handler = mock.return_value
Expand Down Expand Up @@ -846,9 +845,10 @@ async def test_click_humanized_uses_mouse(self, element_with_mouse, mouse_mock):
'result': {'model': {'content': bounds}}
}

await element_with_mouse.click(humanize=True)
humanize = True
await element_with_mouse.click(humanize=humanize)

mouse_mock.click.assert_called_once_with(50.0, 50.0)
mouse_mock.click.assert_called_once_with(50.0, 50.0, humanize=humanize)

@pytest.mark.asyncio
async def test_click_humanized_with_offset(self, element_with_mouse, mouse_mock):
Expand All @@ -860,9 +860,10 @@ async def test_click_humanized_with_offset(self, element_with_mouse, mouse_mock)
'result': {'model': {'content': bounds}}
}

await element_with_mouse.click(x_offset=10, y_offset=20, humanize=True)
humanize = True
await element_with_mouse.click(x_offset=10, y_offset=20, humanize=humanize)

mouse_mock.click.assert_called_once_with(60.0, 70.0)
mouse_mock.click.assert_called_once_with(60.0, 70.0, humanize=humanize)

@pytest.mark.asyncio
async def test_click_humanize_false_uses_raw_cdp(self, element_with_mouse, mouse_mock):
Expand Down Expand Up @@ -2019,7 +2020,6 @@ async def test_get_siblings_elements_element_not_found_exception(self):
"""

import pytest
import pytest_asyncio
from unittest.mock import AsyncMock, patch

from pydoll.elements.web_element import WebElement
Expand All @@ -2028,8 +2028,8 @@ async def test_get_siblings_elements_element_not_found_exception(self):
from pydoll.exceptions import InvalidIFrame


@pytest_asyncio.fixture
async def mock_connection_handler():
@pytest.fixture
def mock_connection_handler():
"""Mock connection handler for WebElement tests."""
with patch('pydoll.connection.ConnectionHandler', autospec=True) as mock:
handler = mock.return_value
Expand Down
Loading