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
83 changes: 50 additions & 33 deletions playwright/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,27 @@
and for the async API [here](async_api.html).
"""

import playwright.types as types
from playwright.main import AsyncPlaywrightContextManager, SyncPlaywrightContextManager
import playwright._types as types
from playwright._main import AsyncPlaywrightContextManager, SyncPlaywrightContextManager

ConsoleMessageLocation = types.ConsoleMessageLocation
Cookie = types.Cookie
Credentials = types.Credentials
DeviceDescriptor = types.DeviceDescriptor
Error = types.Error
FilePayload = types.FilePayload
FloatRect = types.FloatRect
Geolocation = types.Geolocation
IntSize = types.IntSize
MousePosition = types.MousePosition
PdfMargins = types.PdfMargins
ProxyServer = types.ProxyServer
RecordHarOptions = types.RecordHarOptions
RecordVideoOptions = types.RecordVideoOptions
RequestFailure = types.RequestFailure
ResourceTiming = types.ResourceTiming
SelectOption = types.SelectOption
StorageState = types.StorageState
TimeoutError = types.TimeoutError


Expand All @@ -42,35 +59,35 @@ def sync_playwright() -> SyncPlaywrightContextManager:
]

__pdoc__ = {
"accessibility": False,
"async_base": False,
"browser": False,
"browser_context": False,
"browser_type": False,
"cdp_session": False,
"chromium_browser_context": False,
"connection": False,
"console_message": False,
"dialog": False,
"download": False,
"element_handle": False,
"event_context_manager": False,
"file_chooser": False,
"frame": False,
"helper": False,
"impl_to_api_mapping": False,
"input": False,
"js_handle": False,
"main": False,
"network": False,
"object_factory": False,
"page": False,
"path_utils": False,
"playwright": False,
"selectors": False,
"sync_base": False,
"transport": False,
"wait_helper": False,
"async_playwright": False,
"sync_playwright": False,
"_accessibility": False,
"_async_base": False,
"_browser": False,
"_browser_context": False,
"_browser_type": False,
"_cdp_session": False,
"_chromium_browser_context": False,
"_connection": False,
"_console_message": False,
"_dialog": False,
"_download": False,
"_element_handle": False,
"_event_context_manager": False,
"_file_chooser": False,
"_frame": False,
"_helper": False,
"_impl_to_api_mapping": False,
"_input": False,
"_js_handle": False,
"_main": False,
"_network": False,
"_object_factory": False,
"_page": False,
"_path_utils": False,
"_playwright": False,
"_selectors": False,
"_sync_base": False,
"_transport": False,
"_wait_helper": False,
"_async_playwright": False,
"_sync_playwright": False,
}
2 changes: 1 addition & 1 deletion playwright/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from playwright.main import main
from playwright._main import main

main()
6 changes: 3 additions & 3 deletions playwright/accessibility.py → playwright/_accessibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

from typing import Dict, Optional

from playwright.connection import Channel
from playwright.element_handle import ElementHandle
from playwright.helper import locals_to_params
from playwright._connection import Channel
from playwright._element_handle import ElementHandle
from playwright._helper import locals_to_params


def _ax_node_from_protocol(axNode: Dict) -> Dict:
Expand Down
2 changes: 1 addition & 1 deletion playwright/async_base.py → playwright/_async_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import asyncio
from typing import Any, Callable, Coroutine, Generic, Optional, TypeVar, cast

from playwright.impl_to_api_mapping import ImplToApiMapping, ImplWrapper
from playwright._impl_to_api_mapping import ImplToApiMapping, ImplWrapper

mapping = ImplToApiMapping()

Expand Down
14 changes: 7 additions & 7 deletions playwright/browser.py → playwright/_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
from types import SimpleNamespace
from typing import TYPE_CHECKING, Dict, List, Union

from playwright.browser_context import BrowserContext
from playwright.connection import ChannelOwner, from_channel
from playwright.helper import ColorScheme, is_safe_close_error, locals_to_params
from playwright.network import serialize_headers
from playwright.page import Page
from playwright.types import (
from playwright._browser_context import BrowserContext
from playwright._connection import ChannelOwner, from_channel
from playwright._helper import ColorScheme, is_safe_close_error, locals_to_params
from playwright._network import serialize_headers
from playwright._page import Page
from playwright._types import (
Credentials,
Geolocation,
IntSize,
Expand All @@ -37,7 +37,7 @@
from typing_extensions import Literal

if TYPE_CHECKING: # pragma: no cover
from playwright.browser_type import BrowserType
from playwright._browser_type import BrowserType


class Browser(ChannelOwner):
Expand Down
16 changes: 8 additions & 8 deletions playwright/browser_context.py → playwright/_browser_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
from types import SimpleNamespace
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union

from playwright.connection import ChannelOwner, from_channel
from playwright.event_context_manager import EventContextManagerImpl
from playwright.helper import (
from playwright._connection import ChannelOwner, from_channel
from playwright._event_context_manager import EventContextManagerImpl
from playwright._helper import (
PendingWaitEvent,
RouteHandler,
RouteHandlerEntry,
Expand All @@ -29,13 +29,13 @@
is_safe_close_error,
locals_to_params,
)
from playwright.network import Request, Route, serialize_headers
from playwright.page import BindingCall, Page
from playwright.types import Cookie, Error, Geolocation, StorageState
from playwright.wait_helper import WaitHelper
from playwright._network import Request, Route, serialize_headers
from playwright._page import BindingCall, Page
from playwright._types import Cookie, Error, Geolocation, StorageState
from playwright._wait_helper import WaitHelper

if TYPE_CHECKING: # pragma: no cover
from playwright.browser import Browser
from playwright._browser import Browser


class BrowserContext(ChannelOwner):
Expand Down
12 changes: 6 additions & 6 deletions playwright/browser_type.py → playwright/_browser_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
from pathlib import Path
from typing import Dict, List, Union

from playwright.browser import Browser
from playwright.browser_context import BrowserContext
from playwright.connection import ChannelOwner, from_channel
from playwright.helper import ColorScheme, Env, locals_to_params, not_installed_error
from playwright.network import serialize_headers
from playwright.types import (
from playwright._browser import Browser
from playwright._browser_context import BrowserContext
from playwright._connection import ChannelOwner, from_channel
from playwright._helper import ColorScheme, Env, locals_to_params, not_installed_error
from playwright._network import serialize_headers
from playwright._types import (
Credentials,
Geolocation,
IntSize,
Expand Down
6 changes: 3 additions & 3 deletions playwright/cdp_session.py → playwright/_cdp_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

from typing import Any, Dict

from playwright.connection import ChannelOwner
from playwright.helper import locals_to_params
from playwright.js_handle import parse_result
from playwright._connection import ChannelOwner
from playwright._helper import locals_to_params
from playwright._js_handle import parse_result


class CDPSession(ChannelOwner):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
from types import SimpleNamespace
from typing import Dict, List, Set

from playwright.browser_context import BrowserContext
from playwright.cdp_session import CDPSession
from playwright.connection import ChannelOwner, from_channel
from playwright.page import Page, Worker
from playwright._browser_context import BrowserContext
from playwright._cdp_session import CDPSession
from playwright._connection import ChannelOwner, from_channel
from playwright._page import Page, Worker


class ChromiumBrowserContext(BrowserContext):
Expand Down
4 changes: 2 additions & 2 deletions playwright/connection.py → playwright/_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from greenlet import greenlet
from pyee import AsyncIOEventEmitter

from playwright.helper import ParsedMessagePayload, parse_error
from playwright.transport import Transport
from playwright._helper import ParsedMessagePayload, parse_error
from playwright._transport import Transport


class Channel(AsyncIOEventEmitter):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

from typing import Dict, List

from playwright.connection import ChannelOwner, from_channel
from playwright.js_handle import JSHandle
from playwright.types import ConsoleMessageLocation
from playwright._connection import ChannelOwner, from_channel
from playwright._js_handle import JSHandle
from playwright._types import ConsoleMessageLocation


class ConsoleMessage(ChannelOwner):
Expand Down
4 changes: 2 additions & 2 deletions playwright/dialog.py → playwright/_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

from typing import Dict

from playwright.connection import ChannelOwner
from playwright.helper import locals_to_params
from playwright._connection import ChannelOwner
from playwright._helper import locals_to_params


class Dialog(ChannelOwner):
Expand Down
2 changes: 1 addition & 1 deletion playwright/download.py → playwright/_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pathlib import Path
from typing import Dict, Optional, Union

from playwright.connection import ChannelOwner
from playwright._connection import ChannelOwner


class Download(ChannelOwner):
Expand Down
10 changes: 5 additions & 5 deletions playwright/element_handle.py → playwright/_element_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union, cast

from playwright.connection import ChannelOwner, from_nullable_channel
from playwright.helper import (
from playwright._connection import ChannelOwner, from_nullable_channel
from playwright._helper import (
KeyboardModifier,
MouseButton,
SetFilePayload,
locals_to_params,
)
from playwright.js_handle import (
from playwright._js_handle import (
JSHandle,
Serializable,
parse_result,
serialize_argument,
)
from playwright.types import FilePayload, FloatRect, MousePosition, SelectOption
from playwright._types import FilePayload, FloatRect, MousePosition, SelectOption

if sys.version_info >= (3, 8): # pragma: no cover
from typing import Literal
else: # pragma: no cover
from typing_extensions import Literal

if TYPE_CHECKING: # pragma: no cover
from playwright.frame import Frame
from playwright._frame import Frame


class ElementHandle(JSHandle):
Expand Down
6 changes: 3 additions & 3 deletions playwright/file_chooser.py → playwright/_file_chooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

from typing import TYPE_CHECKING, List, Union

from playwright.types import FilePayload
from playwright._types import FilePayload

if TYPE_CHECKING: # pragma: no cover
from playwright.element_handle import ElementHandle
from playwright.page import Page
from playwright._element_handle import ElementHandle
from playwright._page import Page


class FileChooser:
Expand Down
18 changes: 9 additions & 9 deletions playwright/frame.py → playwright/_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@

from pyee import EventEmitter

from playwright.connection import ChannelOwner, from_channel, from_nullable_channel
from playwright.element_handle import (
from playwright._connection import ChannelOwner, from_channel, from_nullable_channel
from playwright._element_handle import (
ElementHandle,
ValuesToSelect,
convert_select_option_values,
normalize_file_payloads,
)
from playwright.event_context_manager import EventContextManagerImpl
from playwright.helper import (
from playwright._event_context_manager import EventContextManagerImpl
from playwright._helper import (
DocumentLoadState,
FrameNavigatedEvent,
KeyboardModifier,
Expand All @@ -38,23 +38,23 @@
locals_to_params,
monotonic_time,
)
from playwright.js_handle import (
from playwright._js_handle import (
JSHandle,
Serializable,
parse_result,
serialize_argument,
)
from playwright.network import Response
from playwright.types import Error, FilePayload, MousePosition
from playwright.wait_helper import WaitHelper
from playwright._network import Response
from playwright._types import Error, FilePayload, MousePosition
from playwright._wait_helper import WaitHelper

if sys.version_info >= (3, 8): # pragma: no cover
from typing import Literal
else: # pragma: no cover
from typing_extensions import Literal

if TYPE_CHECKING: # pragma: no cover
from playwright.page import Page
from playwright._page import Page


class Frame(ChannelOwner):
Expand Down
4 changes: 2 additions & 2 deletions playwright/helper.py → playwright/_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
cast,
)

from playwright.types import Error, TimeoutError
from playwright._types import Error, TimeoutError

if sys.version_info >= (3, 8): # pragma: no cover
from typing import Literal, TypedDict
Expand All @@ -41,7 +41,7 @@


if TYPE_CHECKING: # pragma: no cover
from playwright.network import Request, Route
from playwright._network import Request, Route

URLMatch = Union[str, Pattern, Callable[[str], bool]]
RouteHandler = Callable[["Route", "Request"], Any]
Expand Down
Loading