Calculations#
calculate_boundaries_and_scrollable_area(driver, **kwargs)
#
Calculate and return scrolling boundaries and scrollable area based on crop factors.
Returns:
Name | Type | Description |
---|---|---|
tuple |
tuple[dict, dict]
|
A tuple containing two dictionaries: - boundaries: Dictionary with upper, lower, left, and right bounds - scrollable_area: Dictionary with x and y dimensions |
Source code in src/interaction/gesture/calculations.py
calculate_element_points(element, safe_inset=False)
#
Calculate various points on an element with optional safety insets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element
|
WebElement
|
The WebElement to calculate points for. |
required |
safe_inset
|
bool
|
If True, applies a 10% inset to all edge points for safer interaction. Default is False. |
False
|
Returns:
Type | Description |
---|---|
dict[str, tuple[int, int]]
|
A dictionary containing coordinates of nine points on the element: |
dict[str, tuple[int, int]]
|
|
dict[str, tuple[int, int]]
|
|
dict[str, tuple[int, int]]
|
|
Raises:
Type | Description |
---|---|
ValueError
|
If the element dimensions are invalid. |
Source code in src/interaction/gesture/calculations.py
retrieve_element_location(element)
#
Retrieve the location of an element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element
|
WebElement
|
The WebElement to retrieve the location for. |
required |
Returns:
Type | Description |
---|---|
tuple[int, int]
|
A tuple containing the x and y coordinates of the element. |
Source code in src/interaction/gesture/calculations.py
retrieve_viewport_dimensions(driver)
#
Retrieve the viewport dimensions from the driver.
Returns:
Type | Description |
---|---|
tuple[int, int] | None
|
A tuple of (width, height) or None if dimensions couldn't be retrieved. |