mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
248 lines
6.8 KiB
Python
248 lines
6.8 KiB
Python
# -*- coding:utf-8 -*-
|
|
"""
|
|
@Author : g1879
|
|
@Contact : g1879@qq.com
|
|
"""
|
|
from os import popen
|
|
from typing import Union, Tuple, List
|
|
|
|
from .chromium_base import ChromiumBase, ChromiumBaseSetter
|
|
from .chromium_driver import ChromiumDriver
|
|
from .chromium_tab import ChromiumTab
|
|
from .configs.chromium_options import ChromiumOptions
|
|
from .waiter import ChromiumPageWaiter
|
|
|
|
|
|
class ChromiumPage(ChromiumBase):
|
|
|
|
def __init__(self,
|
|
addr_driver_opts: Union[str, int, ChromiumOptions, ChromiumDriver] = None,
|
|
tab_id: str = None,
|
|
timeout: float = None):
|
|
self._driver_options: ChromiumOptions = ...
|
|
self._process_id: str = ...
|
|
self._window_setter: WindowSetter = ...
|
|
self._main_tab: str = ...
|
|
self._alert: Alert = ...
|
|
self._browser_driver: ChromiumDriver = ...
|
|
self._rect: ChromiumTabRect = ...
|
|
|
|
def _connect_browser(self,
|
|
addr_driver_opts: Union[str, ChromiumDriver] = None,
|
|
tab_id: str = None) -> None: ...
|
|
|
|
def _set_start_options(self, addr_driver_opts: Union[str, ChromiumDriver], none) -> None: ...
|
|
|
|
def _page_init(self) -> None: ...
|
|
|
|
@property
|
|
def browser_driver(self) -> ChromiumDriver: ...
|
|
|
|
@property
|
|
def tabs_count(self) -> int: ...
|
|
|
|
@property
|
|
def tabs(self) -> List[str]: ...
|
|
|
|
@property
|
|
def rect(self) -> ChromiumTabRect: ...
|
|
|
|
@property
|
|
def wait(self) -> ChromiumPageWaiter: ...
|
|
|
|
@property
|
|
def main_tab(self) -> str: ...
|
|
|
|
@property
|
|
def latest_tab(self) -> str: ...
|
|
|
|
@property
|
|
def process_id(self) -> Union[None, int]: ...
|
|
|
|
@property
|
|
def set(self) -> ChromiumPageSetter: ...
|
|
|
|
def get_tab(self, tab_id: str = None) -> ChromiumTab: ...
|
|
|
|
def find_tabs(self, title: str = None, url: str = None,
|
|
tab_type: Union[str, list, tuple, set] = None, single: bool = True) -> Union[str, List[str]]: ...
|
|
|
|
def new_tab(self, url: str = None, switch_to: bool = False) -> str: ...
|
|
|
|
def to_main_tab(self) -> None: ...
|
|
|
|
def to_tab(self, tab_or_id: Union[str, ChromiumTab] = None, activate: bool = True) -> None: ...
|
|
|
|
def _to_tab(self, tab_or_id: Union[str, ChromiumTab] = None, activate: bool = True,
|
|
read_doc: bool = True) -> None: ...
|
|
|
|
def close_tabs(self, tabs_or_ids: Union[
|
|
str, ChromiumTab, List[Union[str, ChromiumTab]], Tuple[Union[str, ChromiumTab]]] = None,
|
|
others: bool = False) -> None: ...
|
|
|
|
def close_other_tabs(self, tabs_or_ids: Union[
|
|
str, ChromiumTab, List[Union[str, ChromiumTab]], Tuple[Union[str, ChromiumTab]]] = None) -> None: ...
|
|
|
|
def handle_alert(self, accept: bool = True, send: str = None, timeout: float = None) -> Union[str, False]: ...
|
|
|
|
def quit(self) -> None: ...
|
|
|
|
def _on_alert_close(self, **kwargs): ...
|
|
|
|
def _on_alert_open(self, **kwargs): ...
|
|
|
|
|
|
class ChromiumTabRect(object):
|
|
def __init__(self, page: ChromiumPage):
|
|
self._page: ChromiumPage = ...
|
|
|
|
@property
|
|
def window_state(self) -> str: ...
|
|
|
|
@property
|
|
def browser_location(self) -> Tuple[int, int]: ...
|
|
|
|
@property
|
|
def page_location(self) -> Tuple[int, int]: ...
|
|
|
|
@property
|
|
def viewport_location(self) -> Tuple[int, int]: ...
|
|
|
|
@property
|
|
def browser_size(self) -> Tuple[int, int]: ...
|
|
|
|
@property
|
|
def page_size(self) -> Tuple[int, int]: ...
|
|
|
|
@property
|
|
def viewport_size(self) -> Tuple[int, int]: ...
|
|
|
|
@property
|
|
def viewport_size_with_scrollbar(self) -> Tuple[int, int]: ...
|
|
|
|
def _get_page_rect(self) -> dict: ...
|
|
|
|
def _get_browser_rect(self) -> dict: ...
|
|
|
|
|
|
# class BaseDownloadSetter(DownloadSetter):
|
|
# def __init__(self, page: ChromiumPage):
|
|
# self._page: ChromiumPage = ...
|
|
# self._behavior: str = ...
|
|
# self._session: Session = ...
|
|
# self._save_path: str = ...
|
|
# self._rename: str = ...
|
|
# self._waiting_download: bool = ...
|
|
# self._download_begin: bool = ...
|
|
# self._browser_missions: Dict[str, BrowserDownloadMission] = ...
|
|
# self._browser_downloading_count: int = ...
|
|
# self._show_msg: bool = ...
|
|
#
|
|
# @property
|
|
# def session(self) -> Session: ...
|
|
#
|
|
# @property
|
|
# def browser_missions(self) -> List[BrowserDownloadMission]: ...
|
|
#
|
|
# @property
|
|
# def DownloadKit_missions(self) -> List[Mission]: ...
|
|
#
|
|
# @property
|
|
# def _switched_DownloadKit(self) -> DownloadKit: ...
|
|
#
|
|
# def save_path(self, path: Union[str, Path]) -> None: ...
|
|
#
|
|
# def rename(self, name: str) -> None: ...
|
|
#
|
|
# def by_browser(self) -> None: ...
|
|
#
|
|
# def by_DownloadKit(self) -> None: ...
|
|
#
|
|
# def wait_download_begin(self, timeout: float = None) -> bool: ...
|
|
#
|
|
# def wait_download_finish(self, timeout: float = None) -> bool: ...
|
|
#
|
|
# def show_msg(self, on_off: bool = True) -> None: ...
|
|
#
|
|
# def _cookies_to_session(self) -> None: ...
|
|
#
|
|
# def _download_by_DownloadKit(self, **kwargs) -> None: ...
|
|
#
|
|
# def _download_will_begin(self, **kwargs) -> None: ...
|
|
#
|
|
# def _download_progress(self, **kwargs) -> None: ...
|
|
#
|
|
# def _wait_download_complete(self, mission: Mission) -> None: ...
|
|
|
|
|
|
class BrowserDownloadMission(object):
|
|
def __init__(self, guid: str, url: str, name: str):
|
|
self.id: str = ...
|
|
self.url: str = ...
|
|
self.name: str = ...
|
|
self.save_path: str = ...
|
|
self.state: str = ...
|
|
self.size: str = ...
|
|
self.received: str = ...
|
|
|
|
|
|
class Alert(object):
|
|
|
|
def __init__(self):
|
|
self.activated: bool = ...
|
|
self.text: str = ...
|
|
self.type: str = ...
|
|
self.defaultPrompt: str = ...
|
|
self.response_accept: str = ...
|
|
self.response_text: str = ...
|
|
|
|
|
|
class WindowSetter(object):
|
|
|
|
def __init__(self, page: ChromiumPage):
|
|
self._page: ChromiumPage = ...
|
|
self._window_id: str = ...
|
|
|
|
def maximized(self) -> None: ...
|
|
|
|
def minimized(self) -> None: ...
|
|
|
|
def fullscreen(self) -> None: ...
|
|
|
|
def normal(self) -> None: ...
|
|
|
|
def size(self, width: int = None, height: int = None) -> None: ...
|
|
|
|
def location(self, x: int = None, y: int = None) -> None: ...
|
|
|
|
def hide(self) -> None: ...
|
|
|
|
def show(self) -> None: ...
|
|
|
|
def _get_info(self) -> dict: ...
|
|
|
|
def _perform(self, bounds: dict) -> None: ...
|
|
|
|
|
|
def show_or_hide_browser(page: ChromiumPage, hide: bool = True) -> None: ...
|
|
|
|
|
|
def get_browser_progress_id(progress: Union[popen, None], address: str) -> Union[str, None]: ...
|
|
|
|
|
|
def get_chrome_hwnds_from_pid(pid: Union[str, int], title: str) -> list: ...
|
|
|
|
|
|
class ChromiumPageSetter(ChromiumBaseSetter):
|
|
_page: ChromiumPage = ...
|
|
|
|
def main_tab(self, tab_id: str = None) -> None: ...
|
|
|
|
@property
|
|
def window(self) -> WindowSetter: ...
|
|
|
|
def tab_to_front(self, tab_or_id: Union[str, ChromiumTab] = None) -> None: ...
|
|
|
|
|
|
def get_rename(original: str, rename: str) -> str: ...
|