Skip to content

Commit

Permalink
Improve Page.click_on_page method
Browse files Browse the repository at this point in the history
Improve Page.click_on_page() method to click
the page coordinates instead of offset relative
to  current mouse position.
  • Loading branch information
M1troll committed Jun 20, 2024
1 parent a7bd776 commit 71e287c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
6 changes: 6 additions & 0 deletions docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ Version history

We follow `Semantic Versions <https://semver.org/>`_.

0.7.4
*******************************************************************************
- Improve ``Page.click_on_page()`` method to click the page coordinates instead
of offset relative to current mouse position


0.7.3
*******************************************************************************
- Add ability to not specify ``app_root`` in ``Page.open_from_url()`` as in ``Page.open()``
Expand Down
20 changes: 7 additions & 13 deletions pomcorn/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,25 +153,19 @@ def navigate_relative(self, relative_url: str = "/") -> None:
)

def click_on_page(self) -> None:
"""Click on (1, 1) coordinates of `html` tag (page upper left corner).
"""Click on (1, 1) coordinates of page (left upper corner).
Allows you to move focus away from an element, for example, if it
is currently unavailable for interaction.
"""
from selenium.webdriver.common.action_chains import ActionChains

from pomcorn import locators

html_webelement = self.init_element(
locator=locators.TagNameLocator("html"),
).get_element()
from selenium.webdriver.common.actions.action_builder import (
ActionBuilder,
)

ActionChains(self.webdriver).move_to_element_with_offset(
to_element=html_webelement,
xoffset=1, # cspell:disable-line
yoffset=1, # cspell:disable-line
).click().perform()
action = ActionBuilder(self.webdriver)
action.pointer_action.move_to_location(1, 1).click()
action.perform()

@staticmethod
def _get_full_relative_url(app_root: str, relative_url: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pomcorn"
version = "0.7.3"
version = "0.7.4"
description = "Base implementation of Page Object Model"
authors = [
"Saritasa <pypi@saritasa.com>",
Expand Down

0 comments on commit 71e287c

Please sign in to comment.