Skip to content
Open
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 .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.22
rev: v0.16.0
hooks:
- id: ruff
args:
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/basic-widgets/text_widget_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
This example demonstrates how to use the Text widget to extract text content.
"""

from widgetastic.widget import Text
from widgetastic.exceptions import NoSuchElementException
from widgetastic.widget import Text

# In-line Initialization of Text widget
main_title = Text(parent=browser, locator=".//h1[@id='wt-core-title']") # noqa: F821
Expand Down
2 changes: 2 additions & 0 deletions docs/examples/browser_setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import inspect
import os
from pathlib import Path

from playwright.sync_api import sync_playwright

from widgetastic.browser import Browser


Expand Down
5 changes: 3 additions & 2 deletions docs/examples/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Pytest configuration for documentation examples."""

import os
import pytest
from pathlib import Path
import sys
from pathlib import Path

import pytest

EXCLUDED_NAMES = {"__init__.py", "conftest.py"}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

from widgetastic.utils import DefaultFillViewStrategy
from widgetastic.widget import View, TextInput, Checkbox, Widget
from widgetastic.widget import Checkbox, TextInput, View, Widget


class BasicForm(View):
Expand Down Expand Up @@ -39,7 +39,7 @@ class BasicForm(View):
# End Example: Filtering None Values

# Example: Handling Extra Keys
import logging # noqa: E402
import logging

logging.basicConfig(level=logging.WARNING)

Expand All @@ -59,8 +59,6 @@ class BasicForm(View):
class NoFillWidget(Widget):
"""Widget without fill method."""

pass


class TestForm(View):
input1 = TextInput(name="input1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Example: Without Inheritance
from widgetastic.utils import WaitFillViewStrategy
from widgetastic.widget import View, TextInput
from widgetastic.widget import TextInput, View


# Example: Without respect_parent (default behavior)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

from widgetastic.utils import WaitFillViewStrategy
from widgetastic.widget import View, TextInput, Checkbox
from widgetastic.widget import Checkbox, TextInput, View


class DynamicForm(View):
Expand Down
7 changes: 4 additions & 3 deletions docs/examples/getting-started/first_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
from pathlib import Path

from playwright.sync_api import sync_playwright

from widgetastic.browser import Browser
from widgetastic.widget import View, Text, TextInput, Checkbox
from widgetastic.widget import Checkbox, Text, TextInput, View


# Define your widgets and views i.e. Modeling of the testing page.
Expand All @@ -21,13 +22,13 @@ class DemoFormView(View):
email = TextInput(locator='.//input[@name="custemail"]')

@View.nested
class pizza_size(View): # noqa
class pizza_size(View):
small = Checkbox(locator=".//input[@value='small']")
medium = Checkbox(locator=".//input[@value='medium']")
large = Checkbox(locator=".//input[@value='large']")

@View.nested
class pizza_toppings(View): # noqa
class pizza_toppings(View):
bacon = Checkbox(locator=".//input[@value='bacon']")
extra_cheese = Checkbox(locator=".//input[@value='cheese']")
onion = Checkbox(locator=".//input[@value='onion']")
Expand Down
4 changes: 3 additions & 1 deletion docs/examples/getting-started/test_installation.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# test_installation.py

import os

from playwright.sync_api import sync_playwright

from widgetastic.browser import Browser
from widgetastic.widget import View, Text
from widgetastic.widget import Text, View


class TestView(View):
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/iframe-handling/basic_iframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This example demonstrates accessing elements inside an iframe.
"""

from widgetastic.widget import View, Text, Select
from widgetastic.widget import Select, Text, View


class BasicIFrameView(View):
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/iframe-handling/context_isolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This example demonstrates that iframe contexts are completely isolated.
"""

from widgetastic.widget import View, Text, Select, Checkbox
from widgetastic.widget import Checkbox, Select, Text, View


class MainPageView(View):
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/iframe-handling/nested_iframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This example demonstrates handling nested iframes (iframe within iframe).
"""

from widgetastic.widget import View, Text, Select, TextInput
from widgetastic.widget import Select, Text, TextInput, View


class NestedIFrameView(View):
Expand All @@ -13,14 +13,14 @@ class NestedIFrameView(View):

# Nested iframe class (iframe within iframe)
@View.nested
class nested_iframe(View): # noqa
class nested_iframe(View):
FRAME = './/iframe[@name="another_iframe"]'
nested_title = Text(".//h3")
nested_select = Select(id="iframe_select3")

# Deeply nested view within the nested iframe
@View.nested
class deep_nested(View): # noqa
class deep_nested(View):
ROOT = './/div[@id="nested_view"]'
nested_input = TextInput(name="input222")

Expand Down
6 changes: 4 additions & 2 deletions docs/examples/version-picking/version_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import inspect
import os
from pathlib import Path

from playwright.sync_api import sync_playwright

from widgetastic.browser import Browser
from widgetastic.utils import VersionPick, Version
from widgetastic.widget import View, Text, TextInput
from widgetastic.utils import Version, VersionPick
from widgetastic.widget import Text, TextInput, View


# Browser setup (from previous example)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/views/basic_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This example demonstrates creating and using a basic View.
"""

from widgetastic.widget import View, Text
from widgetastic.widget import Text, View


class TestingPageView(View):
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/views/batch_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This example demonstrates batch fill and read operations on views.
"""

from widgetastic.widget import View, TextInput, Checkbox
from widgetastic.widget import Checkbox, TextInput, View


class NormalView(View):
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/views/conditional_switchable_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This example demonstrates using ConditionalSwitchableView to handle dynamic UI sections.
"""

from widgetastic.widget import ConditionalSwitchableView, View, TextInput, Select, Checkbox
from widgetastic.widget import Checkbox, ConditionalSwitchableView, Select, TextInput, View


class ConditionalSwitchableViewTesting(View):
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/views/nested_parametrized_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

from widgetastic.utils import ParametrizedLocator, ParametrizedString
from widgetastic.widget import ParametrizedView, TextInput, Checkbox, View, Text
from widgetastic.widget import Checkbox, ParametrizedView, Text, TextInput, View


class ParametrizedViewTesting(View):
Expand All @@ -13,7 +13,7 @@ class ParametrizedViewTesting(View):
ROOT = ".//div[contains(@class, 'parametrized-view')]"
title = Text(locator=".//div[@class='widget-title']")

class thing_container_view(ParametrizedView): # noqa
class thing_container_view(ParametrizedView):
# Defining one parameter
PARAMETERS = ("thing_id",)
# ParametrizedLocator coerces to a string upon access
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/views/nested_view_attribute_assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This example demonstrates creating nested views using View.nested().
"""

from widgetastic.widget import View, Text, TextInput, Checkbox
from widgetastic.widget import Checkbox, Text, TextInput, View


class NormalViewTesting(View):
Expand Down
8 changes: 4 additions & 4 deletions docs/examples/views/nested_view_inner_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
This example demonstrates creating nested views using @View.nested decorator.
"""

from widgetastic.widget import View, Text, TextInput, Checkbox
from widgetastic.widget import Checkbox, Text, TextInput, View


class ViewTesting(View):
@View.nested
class normal_view(View): # noqa
class normal_view(View):
"""Normal View under View testing."""

ROOT = ".//div[contains(@class, 'normal-view')]"
Expand All @@ -19,15 +19,15 @@ class normal_view(View): # noqa
submit = Text(locator=".//button[@id='normal_submit']")

@View.nested
class parametrized_view(View): # noqa
class parametrized_view(View):
"""Parametrized View under View testing."""

ROOT = ".//div[contains(@class, 'parametrized-view')]"
title = Text(locator=".//div[@class='widget-title']")
# Some other widgets

@View.nested
class conditional_switchable_view(View): # noqa
class conditional_switchable_view(View):
"""Conditional Switchable View under View testing."""

ROOT = ".//div[contains(@class, 'conditional-switchable-view')]"
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/views/parametrized_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

from widgetastic.utils import ParametrizedLocator, ParametrizedString
from widgetastic.widget import ParametrizedView, TextInput, Checkbox
from widgetastic.widget import Checkbox, ParametrizedView, TextInput


class ThingContainerView(ParametrizedView):
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/views/parametrized_view_iteration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

from widgetastic.utils import ParametrizedLocator, ParametrizedString
from widgetastic.widget import ParametrizedView, TextInput, Checkbox, View, Text
from widgetastic.widget import Checkbox, ParametrizedView, Text, TextInput, View


class ParametrizedViewTesting(View):
Expand All @@ -13,7 +13,7 @@ class ParametrizedViewTesting(View):
ROOT = ".//div[contains(@class, 'parametrized-view')]"
title = Text(locator=".//div[@class='widget-title']")

class thing_container_view(ParametrizedView): # noqa
class thing_container_view(ParametrizedView):
# Defining one parameter
PARAMETERS = ("thing_id",)
# ParametrizedLocator coerces to a string upon access
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/views/root_locator_scoping.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This example demonstrates how ROOT locators scope widget searches.
"""

from widgetastic.widget import View, Text, TextInput
from widgetastic.widget import Text, TextInput, View


class NormalViewTesting(View):
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/views/simple_conditional_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This example demonstrates registering a simple widget directly with ConditionalSwitchableView.
"""

from widgetastic.widget import ConditionalSwitchableView, View, TextInput, Select
from widgetastic.widget import ConditionalSwitchableView, Select, TextInput, View


class SimpleConditionalWidgetView(View):
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/views/view_lifecycle_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This example demonstrates using before_fill and after_fill hooks.
"""

from widgetastic.widget import View, TextInput, Checkbox
from widgetastic.widget import Checkbox, TextInput, View


class FormView(View):
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/views/view_state_checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This example demonstrates how ROOT locators affect is_displayed behavior.
"""

from widgetastic.widget import View, TextInput
from widgetastic.widget import TextInput, View


# Example 1: Without ROOT locator
Expand Down
2 changes: 2 additions & 0 deletions docs/examples/window-management/basic_windows_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import inspect
import os
from pathlib import Path

from playwright.sync_api import sync_playwright

from widgetastic.browser import Browser, WindowManager


Expand Down
4 changes: 3 additions & 1 deletion docs/examples/window-management/handling_popups.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import inspect
import os
from pathlib import Path

from playwright.sync_api import sync_playwright

from widgetastic.browser import Browser, WindowManager
from widgetastic.widget import View, Text
from widgetastic.widget import Text, View


def setup_window_manager():
Expand Down
Loading
Loading