Skip to content

Commit db9ebef

Browse files
Doc fixes
1 parent ee99593 commit db9ebef

File tree

7 files changed

+184
-170
lines changed

7 files changed

+184
-170
lines changed

docs/source/kitchen_sink/index.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ scrolls
1515

1616
## Overview
1717

18-
This section documents the essential mini-objects, dataclasses,
19-
and helper functions used throughout the framework.
20-
These building blocks are designed to provide a modular,
21-
reusable, and easy-to-understand interface for common
22-
operations, data structures, and utilities.
18+
The **Kitchen Sink** section documents essential mini-objects, dataclasses,
19+
and helper functions used throughout the framework.
20+
These components serve as modular, reusable, and easy-to-understand building
21+
blocks for common operations, data structures, and utilities.
22+
23+
### Available Components
2324

24-
This section covers features and behaviour of `Group` class detail:
2525
- {doc}`Size Dataclass <./size>`
2626
- {doc}`Location Dataclass <./location>`
2727
- {doc}`Driver Dataclass <./driver_container>`
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,42 @@
11
# Locator dataclass
22

3+
## Overview
4+
5+
The `Locator` class is designed to provide a flexible mechanism for managing locators in a unified way.
6+
This class supports different locator types for various platforms and devices, including `desktop`, `mobile`, and `tablet` environments.
7+
The `Locator` class is particularly useful in automation frameworks where locators need to be adapted based on the specific driver
8+
and capabilities being used.
9+
10+
This object and its usage aim to reduce the redundancy of creating multiple attributes for different platforms.
11+
By centralizing locators in a single `Locator` object, it simplifies the codebase and enhances maintainability.
12+
13+
<br>
14+
15+
## Interface
16+
317
```{eval-rst}
418
.. autoclass:: mops.mixins.objects.locator.Locator
519
:undoc-members:
620
:inherited-members:
721
```
22+
23+
<br>
24+
25+
## Usage
26+
27+
The `Locator` class is designed to be flexible and adaptive, making it suitable for various automation scenarios.
28+
Here’s how the attributes work together:
29+
30+
- **`loc_type`** is optional. If not specified, the system will attempt to automatically select the appropriate locator type based on the provided locator.
31+
- **`default`** will be used if no specific locator is provided for the current platform or device.
32+
33+
<br>
34+
35+
### Example
36+
37+
```python
38+
# Providing string parameter instead of Locator object
39+
button = Element('.button', name='button')
40+
41+
search_button = Element(Locator(desktop='.search', mobile='.mobile.search'), name='search button')
42+
```

docs/source/other/locator_object.md

Lines changed: 0 additions & 63 deletions
This file was deleted.

docs/source/other/visual_comparison.md

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Overview
44

55
```{attention}
6-
Supported for `allure` and `pytest` frameworks.
6+
Supported for [allure](https://pypi.org/project/allure-pytest/) and [pytest](https://pypi.org/project/pytest/) frameworks.
77
- `allure` for reporting;
88
- `pytest` for sreenshot name definition.
99
```
@@ -20,39 +20,8 @@ The class also handles dynamic thresholds, image comparison metrics, and can gen
2020
.. autoclass:: mops.visual_comparison.VisualComparison
2121
:exclude-members: calculate_threshold
2222
:members: assert_screenshot
23-
24-
.. attribute:: visual_regression_path: str = ''
25-
- Path where visual regression images (reference, output, and diff) will be stored.
26-
27-
.. attribute:: test_item: pytest.Item = None
28-
- The pytest `request.node.` object associated with the visual comparison.
29-
30-
.. attribute:: attach_diff_image_path: bool = False
31-
- Flag to determine whether to attach the diff image path to the report.
32-
33-
.. attribute:: skip_screenshot_comparison: bool = False
34-
- If set to `True`, the screenshot comparison will be skipped.
35-
36-
.. attribute:: visual_reference_generation: bool = False
37-
- Enables generation of visual references.
38-
39-
.. attribute:: hard_visual_reference_generation: bool = False
40-
- Forces generation of visual references, replacing existing ones.
41-
42-
.. attribute:: soft_visual_reference_generation: bool = False
43-
- Allows generation of visual references only if they do not exist.
44-
45-
.. attribute:: default_delay: Union[int, float] = 0.75
46-
- Default delay before taking a screenshot.
47-
48-
.. attribute:: default_threshold: Union[int, float] = 0
49-
- Default threshold for image comparison.
50-
51-
.. attribute:: dynamic_threshold_factor: int = 0
52-
- Factor for dynamically calculating threshold based on image size.
53-
54-
.. attribute:: diff_color_scheme: tuple = (0, 255, 0)
55-
- Color scheme used for highlighting differences in images.
23+
:undoc-members:
24+
:inherited-members:
5625
```
5726

5827
<br>

docs/source/toc.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ caption: Other
3030
3131
other/objects_initialisation
3232
other/visual_comparison
33-
other/locator_object
3433
```
3534

3635
```{toctree}

mops/mixins/objects/locator.py

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,59 @@
11
from dataclasses import dataclass
2-
from typing import Optional, Any
3-
4-
5-
def take_locator_type(locator: Any):
6-
"""
7-
Safe take locator type from given object
8-
9-
:param locator:
10-
:return:
11-
"""
12-
return locator.loc_type if type(locator) is Locator else None
2+
from typing import Optional, Any, Union
133

144

155
@dataclass
166
class Locator:
177
""" Represents a WEB UI element locator with platform-specific variations. """
188

199
default: Optional[str] = None
10+
"""
11+
All: The default locator for the object, used by default if no other locators are specified
12+
or if no specific platform/device type is detected.
13+
"""
2014
loc_type: Optional[str] = None
15+
"""
16+
Selenium & Appium only: Specifies the locator type
17+
(e.g., :obj:`~selenium.webdriver.common.by.By.CSS_SELECTOR`, :obj:`~selenium.webdriver.common.by.By.XPATH`, etc.).
18+
19+
If not provided, the locator type is automatically determined based on the given locator.
20+
"""
21+
2122
desktop: Optional[str] = None
23+
"""
24+
All: The locator for desktop environments, typically used for browsers on desktop platforms.
25+
"""
26+
2227
mobile: Optional[str] = None
28+
"""
29+
All: The locator for general mobile environments, used for mobile platforms other than iOS and Android,
30+
as well as for mobile resolutions of desktop browsers.
31+
"""
32+
2333
tablet: Optional[str] = None
34+
"""
35+
Appium only: The locator specifically for tablet devices, useful for web and app automation on tablets.
36+
The "is_tablet: True" desired_capability is required.
37+
"""
38+
2439
ios: Optional[str] = None
40+
"""
41+
Appium only: The locator specifically for iOS devices,
42+
allowing for targeting locators specific to iOS applications.
43+
"""
44+
2545
android: Optional[str] = None
46+
"""
47+
Appium only: The locator specifically for Android devices,
48+
allowing for targeting locators specific to Android applications.
49+
"""
50+
51+
52+
def take_locator_type(locator: Union[Locator, str]) -> Union[str, None]:
53+
"""
54+
Safe take locator type from given object.
55+
56+
:param locator: a Locator object or string containing locator.
57+
:return: locator type if given arg is Locator object.
58+
"""
59+
return locator.loc_type if type(locator) is Locator else None

0 commit comments

Comments
 (0)