Updated script that can be controled by Nodejs web app
This commit is contained in:
16
lib/python3.13/site-packages/selenium/webdriver/remote/__init__.py
Executable file
16
lib/python3.13/site-packages/selenium/webdriver/remote/__init__.py
Executable file
@ -0,0 +1,16 @@
|
||||
# Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The SFC licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
23
lib/python3.13/site-packages/selenium/webdriver/remote/bidi_connection.py
Executable file
23
lib/python3.13/site-packages/selenium/webdriver/remote/bidi_connection.py
Executable file
@ -0,0 +1,23 @@
|
||||
# Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The SFC licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
class BidiConnection:
|
||||
def __init__(self, session, cdp, devtools_import) -> None:
|
||||
self.session = session
|
||||
self.cdp = cdp
|
||||
self.devtools = devtools_import
|
258
lib/python3.13/site-packages/selenium/webdriver/remote/client_config.py
Executable file
258
lib/python3.13/site-packages/selenium/webdriver/remote/client_config.py
Executable file
@ -0,0 +1,258 @@
|
||||
# Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The SFC licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import base64
|
||||
import os
|
||||
import socket
|
||||
from typing import Optional
|
||||
from urllib import parse
|
||||
|
||||
import certifi
|
||||
|
||||
from selenium.webdriver.common.proxy import Proxy
|
||||
from selenium.webdriver.common.proxy import ProxyType
|
||||
|
||||
|
||||
class ClientConfig:
|
||||
def __init__(
|
||||
self,
|
||||
remote_server_addr: str,
|
||||
keep_alive: Optional[bool] = True,
|
||||
proxy: Optional[Proxy] = Proxy(raw={"proxyType": ProxyType.SYSTEM}),
|
||||
ignore_certificates: Optional[bool] = False,
|
||||
init_args_for_pool_manager: Optional[dict] = None,
|
||||
timeout: Optional[int] = None,
|
||||
ca_certs: Optional[str] = None,
|
||||
username: Optional[str] = None,
|
||||
password: Optional[str] = None,
|
||||
auth_type: Optional[str] = "Basic",
|
||||
token: Optional[str] = None,
|
||||
) -> None:
|
||||
self.remote_server_addr = remote_server_addr
|
||||
self.keep_alive = keep_alive
|
||||
self.proxy = proxy
|
||||
self.ignore_certificates = ignore_certificates
|
||||
self.init_args_for_pool_manager = init_args_for_pool_manager or {}
|
||||
self.timeout = timeout
|
||||
self.username = username
|
||||
self.password = password
|
||||
self.auth_type = auth_type
|
||||
self.token = token
|
||||
|
||||
self.timeout = (
|
||||
(
|
||||
float(os.getenv("GLOBAL_DEFAULT_TIMEOUT", str(socket.getdefaulttimeout())))
|
||||
if os.getenv("GLOBAL_DEFAULT_TIMEOUT") is not None
|
||||
else socket.getdefaulttimeout()
|
||||
)
|
||||
if timeout is None
|
||||
else timeout
|
||||
)
|
||||
|
||||
self.ca_certs = (
|
||||
(os.getenv("REQUESTS_CA_BUNDLE") if "REQUESTS_CA_BUNDLE" in os.environ else certifi.where())
|
||||
if ca_certs is None
|
||||
else ca_certs
|
||||
)
|
||||
|
||||
@property
|
||||
def remote_server_addr(self) -> str:
|
||||
""":Returns: The address of the remote server."""
|
||||
return self._remote_server_addr
|
||||
|
||||
@remote_server_addr.setter
|
||||
def remote_server_addr(self, value: str) -> None:
|
||||
"""Provides the address of the remote server."""
|
||||
self._remote_server_addr = value
|
||||
|
||||
@property
|
||||
def keep_alive(self) -> bool:
|
||||
""":Returns: The keep alive value."""
|
||||
return self._keep_alive
|
||||
|
||||
@keep_alive.setter
|
||||
def keep_alive(self, value: bool) -> None:
|
||||
"""Toggles the keep alive value.
|
||||
|
||||
:Args:
|
||||
- value: whether to keep the http connection alive
|
||||
"""
|
||||
self._keep_alive = value
|
||||
|
||||
@property
|
||||
def proxy(self) -> Proxy:
|
||||
""":Returns: The proxy used for communicating to the driver/server."""
|
||||
return self._proxy
|
||||
|
||||
@proxy.setter
|
||||
def proxy(self, proxy: Proxy) -> None:
|
||||
"""Provides the information for communicating with the driver or
|
||||
server.
|
||||
For example: Proxy(raw={"proxyType": ProxyType.SYSTEM})
|
||||
|
||||
:Args:
|
||||
- value: the proxy information to use to communicate with the driver or server
|
||||
"""
|
||||
self._proxy = proxy
|
||||
|
||||
@property
|
||||
def ignore_certificates(self) -> bool:
|
||||
""":Returns: The ignore certificate check value."""
|
||||
return self._ignore_certificates
|
||||
|
||||
@ignore_certificates.setter
|
||||
def ignore_certificates(self, ignore_certificates: bool) -> None:
|
||||
"""Toggles the ignore certificate check.
|
||||
|
||||
:Args:
|
||||
- value: value of ignore certificate check
|
||||
"""
|
||||
self._ignore_certificates = ignore_certificates
|
||||
|
||||
@property
|
||||
def init_args_for_pool_manager(self) -> dict:
|
||||
""":Returns: The dictionary of arguments will be appended while
|
||||
initializing the pool manager."""
|
||||
return self._init_args_for_pool_manager
|
||||
|
||||
@init_args_for_pool_manager.setter
|
||||
def init_args_for_pool_manager(self, init_args_for_pool_manager: dict) -> None:
|
||||
"""Provides dictionary of arguments will be appended while initializing the pool manager.
|
||||
For example: {"init_args_for_pool_manager": {"retries": 3, "block": True}}
|
||||
|
||||
:Args:
|
||||
- value: the dictionary of arguments will be appended while initializing the pool manager
|
||||
"""
|
||||
self._init_args_for_pool_manager = init_args_for_pool_manager
|
||||
|
||||
@property
|
||||
def timeout(self) -> int:
|
||||
""":Returns: The timeout (in seconds) used for communicating to the
|
||||
driver/server."""
|
||||
return self._timeout
|
||||
|
||||
@timeout.setter
|
||||
def timeout(self, timeout: int) -> None:
|
||||
"""Provides the timeout (in seconds) for communicating with the driver
|
||||
or server.
|
||||
|
||||
:Args:
|
||||
- value: the timeout (in seconds) to use to communicate with the driver or server
|
||||
"""
|
||||
self._timeout = timeout
|
||||
|
||||
def reset_timeout(self) -> None:
|
||||
"""Resets the timeout to the default value of socket."""
|
||||
self._timeout = socket.getdefaulttimeout()
|
||||
|
||||
@property
|
||||
def ca_certs(self) -> str:
|
||||
""":Returns: The path to bundle of CA certificates."""
|
||||
return self._ca_certs
|
||||
|
||||
@ca_certs.setter
|
||||
def ca_certs(self, ca_certs: str) -> None:
|
||||
"""Provides the path to bundle of CA certificates for establishing
|
||||
secure connections.
|
||||
|
||||
:Args:
|
||||
- value: the path to bundle of CA certificates for establishing secure connections
|
||||
"""
|
||||
self._ca_certs = ca_certs
|
||||
|
||||
@property
|
||||
def username(self) -> str:
|
||||
"""Returns the username used for basic authentication to the remote
|
||||
server."""
|
||||
return self._username
|
||||
|
||||
@username.setter
|
||||
def username(self, value: str) -> None:
|
||||
"""Sets the username used for basic authentication to the remote
|
||||
server."""
|
||||
self._username = value
|
||||
|
||||
@property
|
||||
def password(self) -> str:
|
||||
"""Returns the password used for basic authentication to the remote
|
||||
server."""
|
||||
return self._password
|
||||
|
||||
@password.setter
|
||||
def password(self, value: str) -> None:
|
||||
"""Sets the password used for basic authentication to the remote
|
||||
server."""
|
||||
self._password = value
|
||||
|
||||
@property
|
||||
def auth_type(self) -> str:
|
||||
"""Returns the type of authentication to the remote server."""
|
||||
return self._auth_type
|
||||
|
||||
@auth_type.setter
|
||||
def auth_type(self, value: str) -> None:
|
||||
"""Sets the type of authentication to the remote server if it is not
|
||||
using basic with username and password."""
|
||||
self._auth_type = value
|
||||
|
||||
@property
|
||||
def token(self) -> str:
|
||||
"""Returns the token used for authentication to the remote server."""
|
||||
return self._token
|
||||
|
||||
@token.setter
|
||||
def token(self, value: str) -> None:
|
||||
"""Sets the token used for authentication to the remote server if
|
||||
auth_type is not basic."""
|
||||
self._token = value
|
||||
|
||||
def get_proxy_url(self) -> Optional[str]:
|
||||
"""Returns the proxy URL to use for the connection."""
|
||||
proxy_type = self.proxy.proxy_type
|
||||
remote_add = parse.urlparse(self.remote_server_addr)
|
||||
if proxy_type is ProxyType.DIRECT:
|
||||
return None
|
||||
if proxy_type is ProxyType.SYSTEM:
|
||||
_no_proxy = os.environ.get("no_proxy", os.environ.get("NO_PROXY"))
|
||||
if _no_proxy:
|
||||
for entry in map(str.strip, _no_proxy.split(",")):
|
||||
if entry == "*":
|
||||
return None
|
||||
n_url = parse.urlparse(entry)
|
||||
if n_url.netloc and remote_add.netloc == n_url.netloc:
|
||||
return None
|
||||
if n_url.path in remote_add.netloc:
|
||||
return None
|
||||
return os.environ.get(
|
||||
"https_proxy" if self.remote_server_addr.startswith("https://") else "http_proxy",
|
||||
os.environ.get("HTTPS_PROXY" if self.remote_server_addr.startswith("https://") else "HTTP_PROXY"),
|
||||
)
|
||||
if proxy_type is ProxyType.MANUAL:
|
||||
return self.proxy.sslProxy if self.remote_server_addr.startswith("https://") else self.proxy.http_proxy
|
||||
return None
|
||||
|
||||
def get_auth_header(self) -> Optional[dict]:
|
||||
"""Returns the authorization to add to the request headers."""
|
||||
auth_type = self.auth_type.lower()
|
||||
if auth_type == "basic" and self.username and self.password:
|
||||
credentials = f"{self.username}:{self.password}"
|
||||
encoded_credentials = base64.b64encode(credentials.encode("utf-8")).decode("utf-8")
|
||||
return {"Authorization": f"Basic {encoded_credentials}"}
|
||||
if auth_type == "bearer" and self.token:
|
||||
return {"Authorization": f"Bearer {self.token}"}
|
||||
if auth_type == "oauth" and self.token:
|
||||
return {"Authorization": f"OAuth {self.token}"}
|
||||
return None
|
124
lib/python3.13/site-packages/selenium/webdriver/remote/command.py
Executable file
124
lib/python3.13/site-packages/selenium/webdriver/remote/command.py
Executable file
@ -0,0 +1,124 @@
|
||||
# Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The SFC licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
class Command:
|
||||
"""Defines constants for the standard WebDriver commands.
|
||||
|
||||
While these constants have no meaning in and of themselves, they are
|
||||
used to marshal commands through a service that implements WebDriver's
|
||||
remote wire protocol:
|
||||
|
||||
https://w3c.github.io/webdriver/
|
||||
"""
|
||||
|
||||
NEW_SESSION: str = "newSession"
|
||||
DELETE_SESSION: str = "deleteSession"
|
||||
NEW_WINDOW: str = "newWindow"
|
||||
CLOSE: str = "close"
|
||||
QUIT: str = "quit"
|
||||
GET: str = "get"
|
||||
GO_BACK: str = "goBack"
|
||||
GO_FORWARD: str = "goForward"
|
||||
REFRESH: str = "refresh"
|
||||
ADD_COOKIE: str = "addCookie"
|
||||
GET_COOKIE: str = "getCookie"
|
||||
GET_ALL_COOKIES: str = "getCookies"
|
||||
DELETE_COOKIE: str = "deleteCookie"
|
||||
DELETE_ALL_COOKIES: str = "deleteAllCookies"
|
||||
FIND_ELEMENT: str = "findElement"
|
||||
FIND_ELEMENTS: str = "findElements"
|
||||
FIND_CHILD_ELEMENT: str = "findChildElement"
|
||||
FIND_CHILD_ELEMENTS: str = "findChildElements"
|
||||
CLEAR_ELEMENT: str = "clearElement"
|
||||
CLICK_ELEMENT: str = "clickElement"
|
||||
SEND_KEYS_TO_ELEMENT: str = "sendKeysToElement"
|
||||
W3C_GET_CURRENT_WINDOW_HANDLE: str = "w3cGetCurrentWindowHandle"
|
||||
W3C_GET_WINDOW_HANDLES: str = "w3cGetWindowHandles"
|
||||
SET_WINDOW_RECT: str = "setWindowRect"
|
||||
GET_WINDOW_RECT: str = "getWindowRect"
|
||||
SWITCH_TO_WINDOW: str = "switchToWindow"
|
||||
SWITCH_TO_FRAME: str = "switchToFrame"
|
||||
SWITCH_TO_PARENT_FRAME: str = "switchToParentFrame"
|
||||
W3C_GET_ACTIVE_ELEMENT: str = "w3cGetActiveElement"
|
||||
GET_CURRENT_URL: str = "getCurrentUrl"
|
||||
GET_PAGE_SOURCE: str = "getPageSource"
|
||||
GET_TITLE: str = "getTitle"
|
||||
W3C_EXECUTE_SCRIPT: str = "w3cExecuteScript"
|
||||
W3C_EXECUTE_SCRIPT_ASYNC: str = "w3cExecuteScriptAsync"
|
||||
GET_ELEMENT_TEXT: str = "getElementText"
|
||||
GET_ELEMENT_TAG_NAME: str = "getElementTagName"
|
||||
IS_ELEMENT_SELECTED: str = "isElementSelected"
|
||||
IS_ELEMENT_ENABLED: str = "isElementEnabled"
|
||||
GET_ELEMENT_RECT: str = "getElementRect"
|
||||
GET_ELEMENT_ATTRIBUTE: str = "getElementAttribute"
|
||||
GET_ELEMENT_PROPERTY: str = "getElementProperty"
|
||||
GET_ELEMENT_VALUE_OF_CSS_PROPERTY: str = "getElementValueOfCssProperty"
|
||||
GET_ELEMENT_ARIA_ROLE: str = "getElementAriaRole"
|
||||
GET_ELEMENT_ARIA_LABEL: str = "getElementAriaLabel"
|
||||
SCREENSHOT: str = "screenshot"
|
||||
ELEMENT_SCREENSHOT: str = "elementScreenshot"
|
||||
EXECUTE_ASYNC_SCRIPT: str = "executeAsyncScript"
|
||||
SET_TIMEOUTS: str = "setTimeouts"
|
||||
GET_TIMEOUTS: str = "getTimeouts"
|
||||
W3C_MAXIMIZE_WINDOW: str = "w3cMaximizeWindow"
|
||||
GET_LOG: str = "getLog"
|
||||
GET_AVAILABLE_LOG_TYPES: str = "getAvailableLogTypes"
|
||||
FULLSCREEN_WINDOW: str = "fullscreenWindow"
|
||||
MINIMIZE_WINDOW: str = "minimizeWindow"
|
||||
PRINT_PAGE: str = "printPage"
|
||||
|
||||
# Alerts
|
||||
W3C_DISMISS_ALERT: str = "w3cDismissAlert"
|
||||
W3C_ACCEPT_ALERT: str = "w3cAcceptAlert"
|
||||
W3C_SET_ALERT_VALUE: str = "w3cSetAlertValue"
|
||||
W3C_GET_ALERT_TEXT: str = "w3cGetAlertText"
|
||||
|
||||
# Advanced user interactions
|
||||
W3C_ACTIONS: str = "actions"
|
||||
W3C_CLEAR_ACTIONS: str = "clearActionState"
|
||||
|
||||
# Screen Orientation
|
||||
SET_SCREEN_ORIENTATION: str = "setScreenOrientation"
|
||||
GET_SCREEN_ORIENTATION: str = "getScreenOrientation"
|
||||
|
||||
# Mobile
|
||||
GET_NETWORK_CONNECTION: str = "getNetworkConnection"
|
||||
SET_NETWORK_CONNECTION: str = "setNetworkConnection"
|
||||
CURRENT_CONTEXT_HANDLE: str = "getCurrentContextHandle"
|
||||
CONTEXT_HANDLES: str = "getContextHandles"
|
||||
SWITCH_TO_CONTEXT: str = "switchToContext"
|
||||
|
||||
# Web Components
|
||||
GET_SHADOW_ROOT: str = "getShadowRoot"
|
||||
FIND_ELEMENT_FROM_SHADOW_ROOT: str = "findElementFromShadowRoot"
|
||||
FIND_ELEMENTS_FROM_SHADOW_ROOT: str = "findElementsFromShadowRoot"
|
||||
|
||||
# Virtual Authenticator
|
||||
ADD_VIRTUAL_AUTHENTICATOR: str = "addVirtualAuthenticator"
|
||||
REMOVE_VIRTUAL_AUTHENTICATOR: str = "removeVirtualAuthenticator"
|
||||
ADD_CREDENTIAL: str = "addCredential"
|
||||
GET_CREDENTIALS: str = "getCredentials"
|
||||
REMOVE_CREDENTIAL: str = "removeCredential"
|
||||
REMOVE_ALL_CREDENTIALS: str = "removeAllCredentials"
|
||||
SET_USER_VERIFIED: str = "setUserVerified"
|
||||
|
||||
# Remote File Management
|
||||
UPLOAD_FILE: str = "uploadFile"
|
||||
GET_DOWNLOADABLE_FILES: str = "getDownloadableFiles"
|
||||
DOWNLOAD_FILE: str = "downloadFile"
|
||||
DELETE_DOWNLOADABLE_FILES: str = "deleteDownloadableFiles"
|
229
lib/python3.13/site-packages/selenium/webdriver/remote/errorhandler.py
Executable file
229
lib/python3.13/site-packages/selenium/webdriver/remote/errorhandler.py
Executable file
@ -0,0 +1,229 @@
|
||||
# Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The SFC licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from typing import Any
|
||||
from typing import Dict
|
||||
from typing import Type
|
||||
|
||||
from selenium.common.exceptions import ElementClickInterceptedException
|
||||
from selenium.common.exceptions import ElementNotInteractableException
|
||||
from selenium.common.exceptions import ElementNotSelectableException
|
||||
from selenium.common.exceptions import ElementNotVisibleException
|
||||
from selenium.common.exceptions import ImeActivationFailedException
|
||||
from selenium.common.exceptions import ImeNotAvailableException
|
||||
from selenium.common.exceptions import InsecureCertificateException
|
||||
from selenium.common.exceptions import InvalidArgumentException
|
||||
from selenium.common.exceptions import InvalidCookieDomainException
|
||||
from selenium.common.exceptions import InvalidCoordinatesException
|
||||
from selenium.common.exceptions import InvalidElementStateException
|
||||
from selenium.common.exceptions import InvalidSelectorException
|
||||
from selenium.common.exceptions import InvalidSessionIdException
|
||||
from selenium.common.exceptions import JavascriptException
|
||||
from selenium.common.exceptions import MoveTargetOutOfBoundsException
|
||||
from selenium.common.exceptions import NoAlertPresentException
|
||||
from selenium.common.exceptions import NoSuchCookieException
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from selenium.common.exceptions import NoSuchFrameException
|
||||
from selenium.common.exceptions import NoSuchShadowRootException
|
||||
from selenium.common.exceptions import NoSuchWindowException
|
||||
from selenium.common.exceptions import ScreenshotException
|
||||
from selenium.common.exceptions import SessionNotCreatedException
|
||||
from selenium.common.exceptions import StaleElementReferenceException
|
||||
from selenium.common.exceptions import TimeoutException
|
||||
from selenium.common.exceptions import UnableToSetCookieException
|
||||
from selenium.common.exceptions import UnexpectedAlertPresentException
|
||||
from selenium.common.exceptions import UnknownMethodException
|
||||
from selenium.common.exceptions import WebDriverException
|
||||
|
||||
|
||||
class ExceptionMapping:
|
||||
"""
|
||||
:Maps each errorcode in ErrorCode object to corresponding exception
|
||||
Please refer to https://www.w3.org/TR/webdriver2/#errors for w3c specification
|
||||
"""
|
||||
|
||||
NO_SUCH_ELEMENT = NoSuchElementException
|
||||
NO_SUCH_FRAME = NoSuchFrameException
|
||||
NO_SUCH_SHADOW_ROOT = NoSuchShadowRootException
|
||||
STALE_ELEMENT_REFERENCE = StaleElementReferenceException
|
||||
ELEMENT_NOT_VISIBLE = ElementNotVisibleException
|
||||
INVALID_ELEMENT_STATE = InvalidElementStateException
|
||||
UNKNOWN_ERROR = WebDriverException
|
||||
ELEMENT_IS_NOT_SELECTABLE = ElementNotSelectableException
|
||||
JAVASCRIPT_ERROR = JavascriptException
|
||||
TIMEOUT = TimeoutException
|
||||
NO_SUCH_WINDOW = NoSuchWindowException
|
||||
INVALID_COOKIE_DOMAIN = InvalidCookieDomainException
|
||||
UNABLE_TO_SET_COOKIE = UnableToSetCookieException
|
||||
UNEXPECTED_ALERT_OPEN = UnexpectedAlertPresentException
|
||||
NO_ALERT_OPEN = NoAlertPresentException
|
||||
SCRIPT_TIMEOUT = TimeoutException
|
||||
IME_NOT_AVAILABLE = ImeNotAvailableException
|
||||
IME_ENGINE_ACTIVATION_FAILED = ImeActivationFailedException
|
||||
INVALID_SELECTOR = InvalidSelectorException
|
||||
SESSION_NOT_CREATED = SessionNotCreatedException
|
||||
MOVE_TARGET_OUT_OF_BOUNDS = MoveTargetOutOfBoundsException
|
||||
INVALID_XPATH_SELECTOR = InvalidSelectorException
|
||||
INVALID_XPATH_SELECTOR_RETURN_TYPER = InvalidSelectorException
|
||||
ELEMENT_NOT_INTERACTABLE = ElementNotInteractableException
|
||||
INSECURE_CERTIFICATE = InsecureCertificateException
|
||||
INVALID_ARGUMENT = InvalidArgumentException
|
||||
INVALID_COORDINATES = InvalidCoordinatesException
|
||||
INVALID_SESSION_ID = InvalidSessionIdException
|
||||
NO_SUCH_COOKIE = NoSuchCookieException
|
||||
UNABLE_TO_CAPTURE_SCREEN = ScreenshotException
|
||||
ELEMENT_CLICK_INTERCEPTED = ElementClickInterceptedException
|
||||
UNKNOWN_METHOD = UnknownMethodException
|
||||
|
||||
|
||||
class ErrorCode:
|
||||
"""Error codes defined in the WebDriver wire protocol."""
|
||||
|
||||
# Keep in sync with org.openqa.selenium.remote.ErrorCodes and errorcodes.h
|
||||
SUCCESS = 0
|
||||
NO_SUCH_ELEMENT = [7, "no such element"]
|
||||
NO_SUCH_FRAME = [8, "no such frame"]
|
||||
NO_SUCH_SHADOW_ROOT = ["no such shadow root"]
|
||||
UNKNOWN_COMMAND = [9, "unknown command"]
|
||||
STALE_ELEMENT_REFERENCE = [10, "stale element reference"]
|
||||
ELEMENT_NOT_VISIBLE = [11, "element not visible"]
|
||||
INVALID_ELEMENT_STATE = [12, "invalid element state"]
|
||||
UNKNOWN_ERROR = [13, "unknown error"]
|
||||
ELEMENT_IS_NOT_SELECTABLE = [15, "element not selectable"]
|
||||
JAVASCRIPT_ERROR = [17, "javascript error"]
|
||||
XPATH_LOOKUP_ERROR = [19, "invalid selector"]
|
||||
TIMEOUT = [21, "timeout"]
|
||||
NO_SUCH_WINDOW = [23, "no such window"]
|
||||
INVALID_COOKIE_DOMAIN = [24, "invalid cookie domain"]
|
||||
UNABLE_TO_SET_COOKIE = [25, "unable to set cookie"]
|
||||
UNEXPECTED_ALERT_OPEN = [26, "unexpected alert open"]
|
||||
NO_ALERT_OPEN = [27, "no such alert"]
|
||||
SCRIPT_TIMEOUT = [28, "script timeout"]
|
||||
INVALID_ELEMENT_COORDINATES = [29, "invalid element coordinates"]
|
||||
IME_NOT_AVAILABLE = [30, "ime not available"]
|
||||
IME_ENGINE_ACTIVATION_FAILED = [31, "ime engine activation failed"]
|
||||
INVALID_SELECTOR = [32, "invalid selector"]
|
||||
SESSION_NOT_CREATED = [33, "session not created"]
|
||||
MOVE_TARGET_OUT_OF_BOUNDS = [34, "move target out of bounds"]
|
||||
INVALID_XPATH_SELECTOR = [51, "invalid selector"]
|
||||
INVALID_XPATH_SELECTOR_RETURN_TYPER = [52, "invalid selector"]
|
||||
|
||||
ELEMENT_NOT_INTERACTABLE = [60, "element not interactable"]
|
||||
INSECURE_CERTIFICATE = ["insecure certificate"]
|
||||
INVALID_ARGUMENT = [61, "invalid argument"]
|
||||
INVALID_COORDINATES = ["invalid coordinates"]
|
||||
INVALID_SESSION_ID = ["invalid session id"]
|
||||
NO_SUCH_COOKIE = [62, "no such cookie"]
|
||||
UNABLE_TO_CAPTURE_SCREEN = [63, "unable to capture screen"]
|
||||
ELEMENT_CLICK_INTERCEPTED = [64, "element click intercepted"]
|
||||
UNKNOWN_METHOD = ["unknown method exception"]
|
||||
|
||||
METHOD_NOT_ALLOWED = [405, "unsupported operation"]
|
||||
|
||||
|
||||
class ErrorHandler:
|
||||
"""Handles errors returned by the WebDriver server."""
|
||||
|
||||
def check_response(self, response: Dict[str, Any]) -> None:
|
||||
"""Checks that a JSON response from the WebDriver does not have an
|
||||
error.
|
||||
|
||||
:Args:
|
||||
- response - The JSON response from the WebDriver server as a dictionary
|
||||
object.
|
||||
|
||||
:Raises: If the response contains an error message.
|
||||
"""
|
||||
status = response.get("status", None)
|
||||
if not status or status == ErrorCode.SUCCESS:
|
||||
return
|
||||
value = None
|
||||
message = response.get("message", "")
|
||||
screen: str = response.get("screen", "")
|
||||
stacktrace = None
|
||||
if isinstance(status, int):
|
||||
value_json = response.get("value", None)
|
||||
if value_json and isinstance(value_json, str):
|
||||
import json
|
||||
|
||||
try:
|
||||
value = json.loads(value_json)
|
||||
if len(value) == 1:
|
||||
value = value["value"]
|
||||
status = value.get("error", None)
|
||||
if not status:
|
||||
status = value.get("status", ErrorCode.UNKNOWN_ERROR)
|
||||
message = value.get("value") or value.get("message")
|
||||
if not isinstance(message, str):
|
||||
value = message
|
||||
message = message.get("message")
|
||||
else:
|
||||
message = value.get("message", None)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
exception_class: Type[WebDriverException]
|
||||
e = ErrorCode()
|
||||
error_codes = [item for item in dir(e) if not item.startswith("__")]
|
||||
for error_code in error_codes:
|
||||
error_info = getattr(ErrorCode, error_code)
|
||||
if isinstance(error_info, list) and status in error_info:
|
||||
exception_class = getattr(ExceptionMapping, error_code, WebDriverException)
|
||||
break
|
||||
else:
|
||||
exception_class = WebDriverException
|
||||
|
||||
if not value:
|
||||
value = response["value"]
|
||||
if isinstance(value, str):
|
||||
raise exception_class(value)
|
||||
if message == "" and "message" in value:
|
||||
message = value["message"]
|
||||
|
||||
screen = None # type: ignore[assignment]
|
||||
if "screen" in value:
|
||||
screen = value["screen"]
|
||||
|
||||
stacktrace = None
|
||||
st_value = value.get("stackTrace") or value.get("stacktrace")
|
||||
if st_value:
|
||||
if isinstance(st_value, str):
|
||||
stacktrace = st_value.split("\n")
|
||||
else:
|
||||
stacktrace = []
|
||||
try:
|
||||
for frame in st_value:
|
||||
line = frame.get("lineNumber", "")
|
||||
file = frame.get("fileName", "<anonymous>")
|
||||
if line:
|
||||
file = f"{file}:{line}"
|
||||
meth = frame.get("methodName", "<anonymous>")
|
||||
if "className" in frame:
|
||||
meth = f"{frame['className']}.{meth}"
|
||||
msg = " at %s (%s)"
|
||||
msg = msg % (meth, file)
|
||||
stacktrace.append(msg)
|
||||
except TypeError:
|
||||
pass
|
||||
if exception_class == UnexpectedAlertPresentException:
|
||||
alert_text = None
|
||||
if "data" in value:
|
||||
alert_text = value["data"].get("text")
|
||||
elif "alert" in value:
|
||||
alert_text = value["alert"].get("text")
|
||||
raise exception_class(message, screen, stacktrace, alert_text) # type: ignore[call-arg] # mypy is not smart enough here
|
||||
raise exception_class(message, screen, stacktrace)
|
53
lib/python3.13/site-packages/selenium/webdriver/remote/file_detector.py
Executable file
53
lib/python3.13/site-packages/selenium/webdriver/remote/file_detector.py
Executable file
@ -0,0 +1,53 @@
|
||||
# Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The SFC licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from abc import ABCMeta
|
||||
from abc import abstractmethod
|
||||
from contextlib import suppress
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
from selenium.types import AnyKey
|
||||
from selenium.webdriver.common.utils import keys_to_typing
|
||||
|
||||
|
||||
class FileDetector(metaclass=ABCMeta):
|
||||
"""Used for identifying whether a sequence of chars represents the path to
|
||||
a file."""
|
||||
|
||||
@abstractmethod
|
||||
def is_local_file(self, *keys: AnyKey) -> Optional[str]:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class UselessFileDetector(FileDetector):
|
||||
"""A file detector that never finds anything."""
|
||||
|
||||
def is_local_file(self, *keys: AnyKey) -> Optional[str]:
|
||||
return None
|
||||
|
||||
|
||||
class LocalFileDetector(FileDetector):
|
||||
"""Detects files on the local disk."""
|
||||
|
||||
def is_local_file(self, *keys: AnyKey) -> Optional[str]:
|
||||
file_path = "".join(keys_to_typing(keys))
|
||||
|
||||
with suppress(OSError):
|
||||
if Path(file_path).is_file():
|
||||
return file_path
|
||||
return None
|
122
lib/python3.13/site-packages/selenium/webdriver/remote/findElements.js
Executable file
122
lib/python3.13/site-packages/selenium/webdriver/remote/findElements.js
Executable file
@ -0,0 +1,122 @@
|
||||
function(){return (function(){var aa=this||self;function ba(a){return"string"==typeof a}function ca(a,b){a=a.split(".");var c=aa;a[0]in c||"undefined"==typeof c.execScript||c.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)a.length||void 0===b?c[d]&&c[d]!==Object.prototype[d]?c=c[d]:c=c[d]={}:c[d]=b}
|
||||
function da(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
|
||||
else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function ea(a){return"function"==da(a)}function ha(a){var b=typeof a;return"object"==b&&null!=a||"function"==b}function ia(a,b,c){return a.call.apply(a.bind,arguments)}
|
||||
function ja(a,b,c){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var e=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(e,d);return a.apply(b,e)}}return function(){return a.apply(b,arguments)}}function ka(a,b,c){Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?ka=ia:ka=ja;return ka.apply(null,arguments)}
|
||||
function la(a,b){var c=Array.prototype.slice.call(arguments,1);return function(){var d=c.slice();d.push.apply(d,arguments);return a.apply(this,d)}}function k(a,b){function c(){}c.prototype=b.prototype;a.prototype=new c;a.prototype.constructor=a};/*
|
||||
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2007 Cybozu Labs, Inc.
|
||||
Copyright (c) 2012 Google Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to
|
||||
deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
*/
|
||||
function ma(a,b,c){this.a=a;this.b=b||1;this.f=c||1};var na;var oa=Array.prototype.indexOf?function(a,b){return Array.prototype.indexOf.call(a,b,void 0)}:function(a,b){if("string"===typeof a)return"string"!==typeof b||1!=b.length?-1:a.indexOf(b,0);for(var c=0;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1},l=Array.prototype.forEach?function(a,b,c){Array.prototype.forEach.call(a,b,c)}:function(a,b,c){for(var d=a.length,e="string"===typeof a?a.split(""):a,f=0;f<d;f++)f in e&&b.call(c,e[f],f,a)},pa=Array.prototype.filter?function(a,b){return Array.prototype.filter.call(a,
|
||||
b,void 0)}:function(a,b){for(var c=a.length,d=[],e=0,f="string"===typeof a?a.split(""):a,g=0;g<c;g++)if(g in f){var h=f[g];b.call(void 0,h,g,a)&&(d[e++]=h)}return d},qa=Array.prototype.map?function(a,b){return Array.prototype.map.call(a,b,void 0)}:function(a,b){for(var c=a.length,d=Array(c),e="string"===typeof a?a.split(""):a,f=0;f<c;f++)f in e&&(d[f]=b.call(void 0,e[f],f,a));return d},ra=Array.prototype.reduce?function(a,b,c){return Array.prototype.reduce.call(a,b,c)}:function(a,b,c){var d=c;l(a,
|
||||
function(e,f){d=b.call(void 0,d,e,f,a)});return d},sa=Array.prototype.some?function(a,b){return Array.prototype.some.call(a,b,void 0)}:function(a,b){for(var c=a.length,d="string"===typeof a?a.split(""):a,e=0;e<c;e++)if(e in d&&b.call(void 0,d[e],e,a))return!0;return!1},ta=Array.prototype.every?function(a,b,c){return Array.prototype.every.call(a,b,c)}:function(a,b,c){for(var d=a.length,e="string"===typeof a?a.split(""):a,f=0;f<d;f++)if(f in e&&!b.call(c,e[f],f,a))return!1;return!0};
|
||||
function ua(a,b){a:{for(var c=a.length,d="string"===typeof a?a.split(""):a,e=0;e<c;e++)if(e in d&&b.call(void 0,d[e],e,a)){b=e;break a}b=-1}return 0>b?null:"string"===typeof a?a.charAt(b):a[b]}function va(a){return Array.prototype.concat.apply([],arguments)}function wa(a,b,c){return 2>=arguments.length?Array.prototype.slice.call(a,b):Array.prototype.slice.call(a,b,c)}function xa(a,b){a.sort(b||ya)}function ya(a,b){return a>b?1:a<b?-1:0};function za(a){var b=a.length-1;return 0<=b&&a.indexOf(" ",b)==b}var Aa=String.prototype.trim?function(a){return a.trim()}:function(a){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(a)[1]};
|
||||
function Ba(a,b){var c=0;a=Aa(String(a)).split(".");b=Aa(String(b)).split(".");for(var d=Math.max(a.length,b.length),e=0;0==c&&e<d;e++){var f=a[e]||"",g=b[e]||"";do{f=/(\d*)(\D*)(.*)/.exec(f)||["","","",""];g=/(\d*)(\D*)(.*)/.exec(g)||["","","",""];if(0==f[0].length&&0==g[0].length)break;c=Ca(0==f[1].length?0:parseInt(f[1],10),0==g[1].length?0:parseInt(g[1],10))||Ca(0==f[2].length,0==g[2].length)||Ca(f[2],g[2]);f=f[3];g=g[3]}while(0==c)}return c}function Ca(a,b){return a<b?-1:a>b?1:0};var q;a:{var Da=aa.navigator;if(Da){var Ea=Da.userAgent;if(Ea){q=Ea;break a}}q=""}function r(a){return-1!=q.indexOf(a)};function Fa(){return r("Firefox")||r("FxiOS")}function Ga(){return(r("Chrome")||r("CriOS"))&&!r("Edge")};function Ha(a){return String(a).replace(/\-([a-z])/g,function(b,c){return c.toUpperCase()})};function Ia(){return r("iPhone")&&!r("iPod")&&!r("iPad")};function Ja(a,b){var c=Ka;return Object.prototype.hasOwnProperty.call(c,a)?c[a]:c[a]=b(a)};var La=r("Opera"),t=r("Trident")||r("MSIE"),Ma=r("Edge"),Na=r("Gecko")&&!(-1!=q.toLowerCase().indexOf("webkit")&&!r("Edge"))&&!(r("Trident")||r("MSIE"))&&!r("Edge"),Oa=-1!=q.toLowerCase().indexOf("webkit")&&!r("Edge");function Pa(){var a=aa.document;return a?a.documentMode:void 0}var Qa;
|
||||
a:{var Ra="",Sa=function(){var a=q;if(Na)return/rv:([^\);]+)(\)|;)/.exec(a);if(Ma)return/Edge\/([\d\.]+)/.exec(a);if(t)return/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(a);if(Oa)return/WebKit\/(\S+)/.exec(a);if(La)return/(?:Version)[ \/]?(\S+)/.exec(a)}();Sa&&(Ra=Sa?Sa[1]:"");if(t){var Ta=Pa();if(null!=Ta&&Ta>parseFloat(Ra)){Qa=String(Ta);break a}}Qa=Ra}var Ka={};function Ua(a){return Ja(a,function(){return 0<=Ba(Qa,a)})}var w;w=aa.document&&t?Pa():void 0;var x=t&&!(9<=Number(w)),Va=t&&!(8<=Number(w));function Wa(a,b,c,d){this.a=a;this.nodeName=c;this.nodeValue=d;this.nodeType=2;this.parentNode=this.ownerElement=b}function Xa(a,b){var c=Va&&"href"==b.nodeName?a.getAttribute(b.nodeName,2):b.nodeValue;return new Wa(b,a,b.nodeName,c)};function Ya(a){this.b=a;this.a=0}function Za(a){a=a.match($a);for(var b=0;b<a.length;b++)ab.test(a[b])&&a.splice(b,1);return new Ya(a)}var $a=/\$?(?:(?![0-9-\.])(?:\*|[\w-\.]+):)?(?![0-9-\.])(?:\*|[\w-\.]+)|\/\/|\.\.|::|\d+(?:\.\d*)?|\.\d+|"[^"]*"|'[^']*'|[!<>]=|\s+|./g,ab=/^\s/;function y(a,b){return a.b[a.a+(b||0)]}function z(a){return a.b[a.a++]}function bb(a){return a.b.length<=a.a};function cb(a,b){this.x=void 0!==a?a:0;this.y=void 0!==b?b:0}cb.prototype.ceil=function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this};cb.prototype.floor=function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);return this};cb.prototype.round=function(){this.x=Math.round(this.x);this.y=Math.round(this.y);return this};function db(a,b){this.width=a;this.height=b}db.prototype.aspectRatio=function(){return this.width/this.height};db.prototype.ceil=function(){this.width=Math.ceil(this.width);this.height=Math.ceil(this.height);return this};db.prototype.floor=function(){this.width=Math.floor(this.width);this.height=Math.floor(this.height);return this};db.prototype.round=function(){this.width=Math.round(this.width);this.height=Math.round(this.height);return this};function eb(a){return a?new fb(A(a)):na||(na=new fb)}function gb(a){for(;a&&1!=a.nodeType;)a=a.previousSibling;return a}function hb(a,b){if(!a||!b)return!1;if(a.contains&&1==b.nodeType)return a==b||a.contains(b);if("undefined"!=typeof a.compareDocumentPosition)return a==b||!!(a.compareDocumentPosition(b)&16);for(;b&&a!=b;)b=b.parentNode;return b==a}
|
||||
function ib(a,b){if(a==b)return 0;if(a.compareDocumentPosition)return a.compareDocumentPosition(b)&2?1:-1;if(t&&!(9<=Number(w))){if(9==a.nodeType)return-1;if(9==b.nodeType)return 1}if("sourceIndex"in a||a.parentNode&&"sourceIndex"in a.parentNode){var c=1==a.nodeType,d=1==b.nodeType;if(c&&d)return a.sourceIndex-b.sourceIndex;var e=a.parentNode,f=b.parentNode;return e==f?jb(a,b):!c&&hb(e,b)?-1*kb(a,b):!d&&hb(f,a)?kb(b,a):(c?a.sourceIndex:e.sourceIndex)-(d?b.sourceIndex:f.sourceIndex)}d=A(a);c=d.createRange();
|
||||
c.selectNode(a);c.collapse(!0);a=d.createRange();a.selectNode(b);a.collapse(!0);return c.compareBoundaryPoints(aa.Range.START_TO_END,a)}function kb(a,b){var c=a.parentNode;if(c==b)return-1;for(;b.parentNode!=c;)b=b.parentNode;return jb(b,a)}function jb(a,b){for(;b=b.previousSibling;)if(b==a)return-1;return 1}function A(a){return 9==a.nodeType?a:a.ownerDocument||a.document}function lb(a,b){a&&(a=a.parentNode);for(var c=0;a;){if(b(a))return a;a=a.parentNode;c++}return null}
|
||||
function fb(a){this.a=a||aa.document||document}fb.prototype.getElementsByTagName=function(a,b){return(b||this.a).getElementsByTagName(String(a))};
|
||||
function mb(a,b,c,d){a=d||a.a;var e=b&&"*"!=b?String(b).toUpperCase():"";if(a.querySelectorAll&&a.querySelector&&(e||c))c=a.querySelectorAll(e+(c?"."+c:""));else if(c&&a.getElementsByClassName)if(b=a.getElementsByClassName(c),e){a={};for(var f=d=0,g;g=b[f];f++)e==g.nodeName&&(a[d++]=g);a.length=d;c=a}else c=b;else if(b=a.getElementsByTagName(e||"*"),c){a={};for(f=d=0;g=b[f];f++){e=g.className;var h;if(h="function"==typeof e.split)h=0<=oa(e.split(/\s+/),c);h&&(a[d++]=g)}a.length=d;c=a}else c=b;return c}
|
||||
;function B(a){var b=null,c=a.nodeType;1==c&&(b=a.textContent,b=void 0==b||null==b?a.innerText:b,b=void 0==b||null==b?"":b);if("string"!=typeof b)if(x&&"title"==a.nodeName.toLowerCase()&&1==c)b=a.text;else if(9==c||1==c){a=9==c?a.documentElement:a.firstChild;c=0;var d=[];for(b="";a;){do 1!=a.nodeType&&(b+=a.nodeValue),x&&"title"==a.nodeName.toLowerCase()&&(b+=a.text),d[c++]=a;while(a=a.firstChild);for(;c&&!(a=d[--c].nextSibling););}}else b=a.nodeValue;return b}
|
||||
function nb(a,b,c){if(null===b)return!0;try{if(!a.getAttribute)return!1}catch(d){return!1}Va&&"class"==b&&(b="className");return null==c?!!a.getAttribute(b):a.getAttribute(b,2)==c}function ob(a,b,c,d,e){return(x?pb:qb).call(null,a,b,ba(c)?c:null,ba(d)?d:null,e||new C)}
|
||||
function pb(a,b,c,d,e){if(a instanceof rb||8==a.b||c&&null===a.b){var f=b.all;if(!f)return e;a=sb(a);if("*"!=a&&(f=b.getElementsByTagName(a),!f))return e;if(c){for(var g=[],h=0;b=f[h++];)nb(b,c,d)&&g.push(b);f=g}for(h=0;b=f[h++];)"*"==a&&"!"==b.tagName||e.add(b);return e}tb(a,b,c,d,e);return e}
|
||||
function qb(a,b,c,d,e){b.getElementsByName&&d&&"name"==c&&!t?(b=b.getElementsByName(d),l(b,function(f){a.a(f)&&e.add(f)})):b.getElementsByClassName&&d&&"class"==c?(b=b.getElementsByClassName(d),l(b,function(f){f.className==d&&a.a(f)&&e.add(f)})):a instanceof D?tb(a,b,c,d,e):b.getElementsByTagName&&(b=b.getElementsByTagName(a.f()),l(b,function(f){nb(f,c,d)&&e.add(f)}));return e}
|
||||
function ub(a,b,c,d,e){var f;if((a instanceof rb||8==a.b||c&&null===a.b)&&(f=b.childNodes)){var g=sb(a);if("*"!=g&&(f=pa(f,function(h){return h.tagName&&h.tagName.toLowerCase()==g}),!f))return e;c&&(f=pa(f,function(h){return nb(h,c,d)}));l(f,function(h){"*"==g&&("!"==h.tagName||"*"==g&&1!=h.nodeType)||e.add(h)});return e}return vb(a,b,c,d,e)}function vb(a,b,c,d,e){for(b=b.firstChild;b;b=b.nextSibling)nb(b,c,d)&&a.a(b)&&e.add(b);return e}
|
||||
function tb(a,b,c,d,e){for(b=b.firstChild;b;b=b.nextSibling)nb(b,c,d)&&a.a(b)&&e.add(b),tb(a,b,c,d,e)}function sb(a){if(a instanceof D){if(8==a.b)return"!";if(null===a.b)return"*"}return a.f()};function C(){this.b=this.a=null;this.m=0}function wb(a){this.f=a;this.a=this.b=null}function xb(a,b){if(!a.a)return b;if(!b.a)return a;var c=a.a;b=b.a;for(var d=null,e,f=0;c&&b;){e=c.f;var g=b.f;e==g||e instanceof Wa&&g instanceof Wa&&e.a==g.a?(e=c,c=c.a,b=b.a):0<ib(c.f,b.f)?(e=b,b=b.a):(e=c,c=c.a);(e.b=d)?d.a=e:a.a=e;d=e;f++}for(e=c||b;e;)e.b=d,d=d.a=e,f++,e=e.a;a.b=d;a.m=f;return a}function yb(a,b){b=new wb(b);b.a=a.a;a.b?a.a.b=b:a.a=a.b=b;a.a=b;a.m++}
|
||||
C.prototype.add=function(a){a=new wb(a);a.b=this.b;this.a?this.b.a=a:this.a=this.b=a;this.b=a;this.m++};function zb(a){return(a=a.a)?a.f:null}function Bb(a){return(a=zb(a))?B(a):""}function Cb(a,b){return new Db(a,!!b)}function Db(a,b){this.f=a;this.b=(this.A=b)?a.b:a.a;this.a=null}function E(a){var b=a.b;if(null==b)return null;var c=a.a=b;a.b=a.A?b.b:b.a;return c.f};function F(a){this.i=a;this.b=this.g=!1;this.f=null}function H(a){return"\n "+a.toString().split("\n").join("\n ")}function Eb(a,b){a.g=b}function Fb(a,b){a.b=b}function I(a,b){a=a.a(b);return a instanceof C?+Bb(a):+a}function J(a,b){a=a.a(b);return a instanceof C?Bb(a):""+a}function Gb(a,b){a=a.a(b);return a instanceof C?!!a.m:!!a};function Hb(a,b,c){F.call(this,a.i);this.c=a;this.h=b;this.v=c;this.g=b.g||c.g;this.b=b.b||c.b;this.c==Ib&&(c.b||c.g||4==c.i||0==c.i||!b.f?b.b||b.g||4==b.i||0==b.i||!c.f||(this.f={name:c.f.name,B:b}):this.f={name:b.f.name,B:c})}k(Hb,F);
|
||||
function Jb(a,b,c,d,e){b=b.a(d);c=c.a(d);var f;if(b instanceof C&&c instanceof C){b=Cb(b);for(d=E(b);d;d=E(b))for(e=Cb(c),f=E(e);f;f=E(e))if(a(B(d),B(f)))return!0;return!1}if(b instanceof C||c instanceof C){b instanceof C?(e=b,d=c):(e=c,d=b);f=Cb(e);for(var g=typeof d,h=E(f);h;h=E(f)){switch(g){case "number":h=+B(h);break;case "boolean":h=!!B(h);break;case "string":h=B(h);break;default:throw Error("Illegal primitive type for comparison.");}if(e==b&&a(h,d)||e==c&&a(d,h))return!0}return!1}return e?
|
||||
"boolean"==typeof b||"boolean"==typeof c?a(!!b,!!c):"number"==typeof b||"number"==typeof c?a(+b,+c):a(b,c):a(+b,+c)}Hb.prototype.a=function(a){return this.c.s(this.h,this.v,a)};Hb.prototype.toString=function(){var a="Binary Expression: "+this.c;a+=H(this.h);return a+=H(this.v)};function Kb(a,b,c,d){this.$=a;this.M=b;this.i=c;this.s=d}Kb.prototype.toString=function(){return this.$};var Lb={};
|
||||
function K(a,b,c,d){if(Lb.hasOwnProperty(a))throw Error("Binary operator already created: "+a);a=new Kb(a,b,c,d);return Lb[a.toString()]=a}K("div",6,1,function(a,b,c){return I(a,c)/I(b,c)});K("mod",6,1,function(a,b,c){return I(a,c)%I(b,c)});K("*",6,1,function(a,b,c){return I(a,c)*I(b,c)});K("+",5,1,function(a,b,c){return I(a,c)+I(b,c)});K("-",5,1,function(a,b,c){return I(a,c)-I(b,c)});K("<",4,2,function(a,b,c){return Jb(function(d,e){return d<e},a,b,c)});
|
||||
K(">",4,2,function(a,b,c){return Jb(function(d,e){return d>e},a,b,c)});K("<=",4,2,function(a,b,c){return Jb(function(d,e){return d<=e},a,b,c)});K(">=",4,2,function(a,b,c){return Jb(function(d,e){return d>=e},a,b,c)});var Ib=K("=",3,2,function(a,b,c){return Jb(function(d,e){return d==e},a,b,c,!0)});K("!=",3,2,function(a,b,c){return Jb(function(d,e){return d!=e},a,b,c,!0)});K("and",2,2,function(a,b,c){return Gb(a,c)&&Gb(b,c)});K("or",1,2,function(a,b,c){return Gb(a,c)||Gb(b,c)});function Mb(a,b){if(b.a.length&&4!=a.i)throw Error("Primary expression must evaluate to nodeset if filter has predicate(s).");F.call(this,a.i);this.c=a;this.h=b;this.g=a.g;this.b=a.b}k(Mb,F);Mb.prototype.a=function(a){a=this.c.a(a);return Nb(this.h,a)};Mb.prototype.toString=function(){var a="Filter:"+H(this.c);return a+=H(this.h)};function Ob(a,b){if(b.length<a.L)throw Error("Function "+a.l+" expects at least"+a.L+" arguments, "+b.length+" given");if(null!==a.H&&b.length>a.H)throw Error("Function "+a.l+" expects at most "+a.H+" arguments, "+b.length+" given");a.Z&&l(b,function(c,d){if(4!=c.i)throw Error("Argument "+d+" to function "+a.l+" is not of type Nodeset: "+c);});F.call(this,a.i);this.D=a;this.c=b;Eb(this,a.g||sa(b,function(c){return c.g}));Fb(this,a.Y&&!b.length||a.X&&!!b.length||sa(b,function(c){return c.b}))}
|
||||
k(Ob,F);Ob.prototype.a=function(a){return this.D.s.apply(null,va(a,this.c))};Ob.prototype.toString=function(){var a="Function: "+this.D;if(this.c.length){var b=ra(this.c,function(c,d){return c+H(d)},"Arguments:");a+=H(b)}return a};function Pb(a,b,c,d,e,f,g,h){this.l=a;this.i=b;this.g=c;this.Y=d;this.X=!1;this.s=e;this.L=f;this.H=void 0!==g?g:f;this.Z=!!h}Pb.prototype.toString=function(){return this.l};var Qb={};
|
||||
function L(a,b,c,d,e,f,g,h){if(Qb.hasOwnProperty(a))throw Error("Function already created: "+a+".");Qb[a]=new Pb(a,b,c,d,e,f,g,h)}L("boolean",2,!1,!1,function(a,b){return Gb(b,a)},1);L("ceiling",1,!1,!1,function(a,b){return Math.ceil(I(b,a))},1);L("concat",3,!1,!1,function(a,b){return ra(wa(arguments,1),function(c,d){return c+J(d,a)},"")},2,null);L("contains",2,!1,!1,function(a,b,c){b=J(b,a);a=J(c,a);return a=-1!=b.indexOf(a)},2);L("count",1,!1,!1,function(a,b){return b.a(a).m},1,1,!0);
|
||||
L("false",2,!1,!1,function(){return!1},0);L("floor",1,!1,!1,function(a,b){return Math.floor(I(b,a))},1);L("id",4,!1,!1,function(a,b){function c(h){if(x){var n=e.all[h];if(n){if(n.nodeType&&h==n.id)return n;if(n.length)return ua(n,function(u){return h==u.id})}return null}return e.getElementById(h)}var d=a.a,e=9==d.nodeType?d:d.ownerDocument;a=J(b,a).split(/\s+/);var f=[];l(a,function(h){h=c(h);!h||0<=oa(f,h)||f.push(h)});f.sort(ib);var g=new C;l(f,function(h){g.add(h)});return g},1);
|
||||
L("lang",2,!1,!1,function(){return!1},1);L("last",1,!0,!1,function(a){if(1!=arguments.length)throw Error("Function last expects ()");return a.f},0);L("local-name",3,!1,!0,function(a,b){return(a=b?zb(b.a(a)):a.a)?a.localName||a.nodeName.toLowerCase():""},0,1,!0);L("name",3,!1,!0,function(a,b){return(a=b?zb(b.a(a)):a.a)?a.nodeName.toLowerCase():""},0,1,!0);L("namespace-uri",3,!0,!1,function(){return""},0,1,!0);
|
||||
L("normalize-space",3,!1,!0,function(a,b){return(b?J(b,a):B(a.a)).replace(/[\s\xa0]+/g," ").replace(/^\s+|\s+$/g,"")},0,1);L("not",2,!1,!1,function(a,b){return!Gb(b,a)},1);L("number",1,!1,!0,function(a,b){return b?I(b,a):+B(a.a)},0,1);L("position",1,!0,!1,function(a){return a.b},0);L("round",1,!1,!1,function(a,b){return Math.round(I(b,a))},1);L("starts-with",2,!1,!1,function(a,b,c){b=J(b,a);a=J(c,a);return 0==b.lastIndexOf(a,0)},2);L("string",3,!1,!0,function(a,b){return b?J(b,a):B(a.a)},0,1);
|
||||
L("string-length",1,!1,!0,function(a,b){return(b?J(b,a):B(a.a)).length},0,1);L("substring",3,!1,!1,function(a,b,c,d){c=I(c,a);if(isNaN(c)||Infinity==c||-Infinity==c)return"";d=d?I(d,a):Infinity;if(isNaN(d)||-Infinity===d)return"";c=Math.round(c)-1;var e=Math.max(c,0);a=J(b,a);return Infinity==d?a.substring(e):a.substring(e,c+Math.round(d))},2,3);L("substring-after",3,!1,!1,function(a,b,c){b=J(b,a);a=J(c,a);c=b.indexOf(a);return-1==c?"":b.substring(c+a.length)},2);
|
||||
L("substring-before",3,!1,!1,function(a,b,c){b=J(b,a);a=J(c,a);a=b.indexOf(a);return-1==a?"":b.substring(0,a)},2);L("sum",1,!1,!1,function(a,b){a=Cb(b.a(a));b=0;for(var c=E(a);c;c=E(a))b+=+B(c);return b},1,1,!0);L("translate",3,!1,!1,function(a,b,c,d){b=J(b,a);c=J(c,a);var e=J(d,a);a={};for(d=0;d<c.length;d++){var f=c.charAt(d);f in a||(a[f]=e.charAt(d))}c="";for(d=0;d<b.length;d++)f=b.charAt(d),c+=f in a?a[f]:f;return c},3);L("true",2,!1,!1,function(){return!0},0);function D(a,b){this.h=a;this.c=void 0!==b?b:null;this.b=null;switch(a){case "comment":this.b=8;break;case "text":this.b=3;break;case "processing-instruction":this.b=7;break;case "node":break;default:throw Error("Unexpected argument");}}function Rb(a){return"comment"==a||"text"==a||"processing-instruction"==a||"node"==a}D.prototype.a=function(a){return null===this.b||this.b==a.nodeType};D.prototype.f=function(){return this.h};
|
||||
D.prototype.toString=function(){var a="Kind Test: "+this.h;null===this.c||(a+=H(this.c));return a};function Sb(a){F.call(this,3);this.c=a.substring(1,a.length-1)}k(Sb,F);Sb.prototype.a=function(){return this.c};Sb.prototype.toString=function(){return"Literal: "+this.c};function rb(a,b){this.l=a.toLowerCase();a="*"==this.l?"*":"http://www.w3.org/1999/xhtml";this.c=b?b.toLowerCase():a}rb.prototype.a=function(a){var b=a.nodeType;if(1!=b&&2!=b)return!1;b=void 0!==a.localName?a.localName:a.nodeName;return"*"!=this.l&&this.l!=b.toLowerCase()?!1:"*"==this.c?!0:this.c==(a.namespaceURI?a.namespaceURI.toLowerCase():"http://www.w3.org/1999/xhtml")};rb.prototype.f=function(){return this.l};
|
||||
rb.prototype.toString=function(){return"Name Test: "+("http://www.w3.org/1999/xhtml"==this.c?"":this.c+":")+this.l};function Tb(a){F.call(this,1);this.c=a}k(Tb,F);Tb.prototype.a=function(){return this.c};Tb.prototype.toString=function(){return"Number: "+this.c};function Ub(a,b){F.call(this,a.i);this.h=a;this.c=b;this.g=a.g;this.b=a.b;1==this.c.length&&(a=this.c[0],a.G||a.c!=Vb||(a=a.v,"*"!=a.f()&&(this.f={name:a.f(),B:null})))}k(Ub,F);function Wb(){F.call(this,4)}k(Wb,F);Wb.prototype.a=function(a){var b=new C;a=a.a;9==a.nodeType?b.add(a):b.add(a.ownerDocument);return b};Wb.prototype.toString=function(){return"Root Helper Expression"};function Xb(){F.call(this,4)}k(Xb,F);Xb.prototype.a=function(a){var b=new C;b.add(a.a);return b};Xb.prototype.toString=function(){return"Context Helper Expression"};
|
||||
function Yb(a){return"/"==a||"//"==a}Ub.prototype.a=function(a){var b=this.h.a(a);if(!(b instanceof C))throw Error("Filter expression must evaluate to nodeset.");a=this.c;for(var c=0,d=a.length;c<d&&b.m;c++){var e=a[c],f=Cb(b,e.c.A);if(e.g||e.c!=Zb)if(e.g||e.c!=$b){var g=E(f);for(b=e.a(new ma(g));null!=(g=E(f));)g=e.a(new ma(g)),b=xb(b,g)}else g=E(f),b=e.a(new ma(g));else{for(g=E(f);(b=E(f))&&(!g.contains||g.contains(b))&&b.compareDocumentPosition(g)&8;g=b);b=e.a(new ma(g))}}return b};
|
||||
Ub.prototype.toString=function(){var a="Path Expression:"+H(this.h);if(this.c.length){var b=ra(this.c,function(c,d){return c+H(d)},"Steps:");a+=H(b)}return a};function ac(a,b){this.a=a;this.A=!!b}
|
||||
function Nb(a,b,c){for(c=c||0;c<a.a.length;c++)for(var d=a.a[c],e=Cb(b),f=b.m,g,h=0;g=E(e);h++){var n=a.A?f-h:h+1;g=d.a(new ma(g,n,f));if("number"==typeof g)n=n==g;else if("string"==typeof g||"boolean"==typeof g)n=!!g;else if(g instanceof C)n=0<g.m;else throw Error("Predicate.evaluate returned an unexpected type.");if(!n){n=e;g=n.f;var u=n.a;if(!u)throw Error("Next must be called at least once before remove.");var p=u.b;u=u.a;p?p.a=u:g.a=u;u?u.b=p:g.b=p;g.m--;n.a=null}}return b}
|
||||
ac.prototype.toString=function(){return ra(this.a,function(a,b){return a+H(b)},"Predicates:")};function bc(a,b,c,d){F.call(this,4);this.c=a;this.v=b;this.h=c||new ac([]);this.G=!!d;b=this.h;b=0<b.a.length?b.a[0].f:null;a.ca&&b&&(a=b.name,a=x?a.toLowerCase():a,this.f={name:a,B:b.B});a:{a=this.h;for(b=0;b<a.a.length;b++)if(c=a.a[b],c.g||1==c.i||0==c.i){a=!0;break a}a=!1}this.g=a}k(bc,F);
|
||||
bc.prototype.a=function(a){var b=a.a,c=this.f,d=null,e=null,f=0;c&&(d=c.name,e=c.B?J(c.B,a):null,f=1);if(this.G)if(this.g||this.c!=cc)if(b=Cb((new bc(dc,new D("node"))).a(a)),c=E(b))for(a=this.s(c,d,e,f);null!=(c=E(b));)a=xb(a,this.s(c,d,e,f));else a=new C;else a=ob(this.v,b,d,e),a=Nb(this.h,a,f);else a=this.s(a.a,d,e,f);return a};bc.prototype.s=function(a,b,c,d){a=this.c.D(this.v,a,b,c);return a=Nb(this.h,a,d)};
|
||||
bc.prototype.toString=function(){var a="Step:"+H("Operator: "+(this.G?"//":"/"));this.c.l&&(a+=H("Axis: "+this.c));a+=H(this.v);if(this.h.a.length){var b=ra(this.h.a,function(c,d){return c+H(d)},"Predicates:");a+=H(b)}return a};function ec(a,b,c,d){this.l=a;this.D=b;this.A=c;this.ca=d}ec.prototype.toString=function(){return this.l};var fc={};function M(a,b,c,d){if(fc.hasOwnProperty(a))throw Error("Axis already created: "+a);b=new ec(a,b,c,!!d);return fc[a]=b}
|
||||
M("ancestor",function(a,b){for(var c=new C;b=b.parentNode;)a.a(b)&&yb(c,b);return c},!0);M("ancestor-or-self",function(a,b){var c=new C;do a.a(b)&&yb(c,b);while(b=b.parentNode);return c},!0);
|
||||
var Vb=M("attribute",function(a,b){var c=new C,d=a.f();if("style"==d&&x&&b.style)return c.add(new Wa(b.style,b,"style",b.style.cssText)),c;var e=b.attributes;if(e)if(a instanceof D&&null===a.b||"*"==d)for(a=0;d=e[a];a++)x?d.nodeValue&&c.add(Xa(b,d)):c.add(d);else(d=e.getNamedItem(d))&&(x?d.nodeValue&&c.add(Xa(b,d)):c.add(d));return c},!1),cc=M("child",function(a,b,c,d,e){return(x?ub:vb).call(null,a,b,ba(c)?c:null,ba(d)?d:null,e||new C)},!1,!0);M("descendant",ob,!1,!0);
|
||||
var dc=M("descendant-or-self",function(a,b,c,d){var e=new C;nb(b,c,d)&&a.a(b)&&e.add(b);return ob(a,b,c,d,e)},!1,!0),Zb=M("following",function(a,b,c,d){var e=new C;do for(var f=b;f=f.nextSibling;)nb(f,c,d)&&a.a(f)&&e.add(f),e=ob(a,f,c,d,e);while(b=b.parentNode);return e},!1,!0);M("following-sibling",function(a,b){for(var c=new C;b=b.nextSibling;)a.a(b)&&c.add(b);return c},!1);M("namespace",function(){return new C},!1);
|
||||
var gc=M("parent",function(a,b){var c=new C;if(9==b.nodeType)return c;if(2==b.nodeType)return c.add(b.ownerElement),c;b=b.parentNode;a.a(b)&&c.add(b);return c},!1),$b=M("preceding",function(a,b,c,d){var e=new C,f=[];do f.unshift(b);while(b=b.parentNode);for(var g=1,h=f.length;g<h;g++){var n=[];for(b=f[g];b=b.previousSibling;)n.unshift(b);for(var u=0,p=n.length;u<p;u++)b=n[u],nb(b,c,d)&&a.a(b)&&e.add(b),e=ob(a,b,c,d,e)}return e},!0,!0);
|
||||
M("preceding-sibling",function(a,b){for(var c=new C;b=b.previousSibling;)a.a(b)&&yb(c,b);return c},!0);var hc=M("self",function(a,b){var c=new C;a.a(b)&&c.add(b);return c},!1);function ic(a){F.call(this,1);this.c=a;this.g=a.g;this.b=a.b}k(ic,F);ic.prototype.a=function(a){return-I(this.c,a)};ic.prototype.toString=function(){return"Unary Expression: -"+H(this.c)};function jc(a){F.call(this,4);this.c=a;Eb(this,sa(this.c,function(b){return b.g}));Fb(this,sa(this.c,function(b){return b.b}))}k(jc,F);jc.prototype.a=function(a){var b=new C;l(this.c,function(c){c=c.a(a);if(!(c instanceof C))throw Error("Path expression must evaluate to NodeSet.");b=xb(b,c)});return b};jc.prototype.toString=function(){return ra(this.c,function(a,b){return a+H(b)},"Union Expression:")};function kc(a,b){this.a=a;this.b=b}function lc(a){for(var b,c=[];;){N(a,"Missing right hand side of binary expression.");b=mc(a);var d=z(a.a);if(!d)break;var e=(d=Lb[d]||null)&&d.M;if(!e){a.a.a--;break}for(;c.length&&e<=c[c.length-1].M;)b=new Hb(c.pop(),c.pop(),b);c.push(b,d)}for(;c.length;)b=new Hb(c.pop(),c.pop(),b);return b}function N(a,b){if(bb(a.a))throw Error(b);}function nc(a,b){a=z(a.a);if(a!=b)throw Error("Bad token, expected: "+b+" got: "+a);}
|
||||
function oc(a){a=z(a.a);if(")"!=a)throw Error("Bad token: "+a);}function rc(a){a=z(a.a);if(2>a.length)throw Error("Unclosed literal string");return new Sb(a)}
|
||||
function sc(a){var b=[];if(Yb(y(a.a))){var c=z(a.a);var d=y(a.a);if("/"==c&&(bb(a.a)||"."!=d&&".."!=d&&"@"!=d&&"*"!=d&&!/(?![0-9])[\w]/.test(d)))return new Wb;d=new Wb;N(a,"Missing next location step.");c=tc(a,c);b.push(c)}else{a:{c=y(a.a);d=c.charAt(0);switch(d){case "$":throw Error("Variable reference not allowed in HTML XPath");case "(":z(a.a);c=lc(a);N(a,'unclosed "("');nc(a,")");break;case '"':case "'":c=rc(a);break;default:if(isNaN(+c))if(!Rb(c)&&/(?![0-9])[\w]/.test(d)&&"("==y(a.a,1)){c=z(a.a);
|
||||
c=Qb[c]||null;z(a.a);for(d=[];")"!=y(a.a);){N(a,"Missing function argument list.");d.push(lc(a));if(","!=y(a.a))break;z(a.a)}N(a,"Unclosed function argument list.");oc(a);c=new Ob(c,d)}else{c=null;break a}else c=new Tb(+z(a.a))}"["==y(a.a)&&(d=new ac(uc(a)),c=new Mb(c,d))}if(c)if(Yb(y(a.a)))d=c;else return c;else c=tc(a,"/"),d=new Xb,b.push(c)}for(;Yb(y(a.a));)c=z(a.a),N(a,"Missing next location step."),c=tc(a,c),b.push(c);return new Ub(d,b)}
|
||||
function tc(a,b){if("/"!=b&&"//"!=b)throw Error('Step op should be "/" or "//"');if("."==y(a.a)){var c=new bc(hc,new D("node"));z(a.a);return c}if(".."==y(a.a))return c=new bc(gc,new D("node")),z(a.a),c;if("@"==y(a.a)){var d=Vb;z(a.a);N(a,"Missing attribute name")}else if("::"==y(a.a,1)){if(!/(?![0-9])[\w]/.test(y(a.a).charAt(0)))throw Error("Bad token: "+z(a.a));var e=z(a.a);d=fc[e]||null;if(!d)throw Error("No axis with name: "+e);z(a.a);N(a,"Missing node name")}else d=cc;e=y(a.a);if(/(?![0-9])[\w\*]/.test(e.charAt(0)))if("("==
|
||||
y(a.a,1)){if(!Rb(e))throw Error("Invalid node type: "+e);e=z(a.a);if(!Rb(e))throw Error("Invalid type name: "+e);nc(a,"(");N(a,"Bad nodetype");var f=y(a.a).charAt(0),g=null;if('"'==f||"'"==f)g=rc(a);N(a,"Bad nodetype");oc(a);e=new D(e,g)}else if(e=z(a.a),f=e.indexOf(":"),-1==f)e=new rb(e);else{g=e.substring(0,f);if("*"==g)var h="*";else if(h=a.b(g),!h)throw Error("Namespace prefix not declared: "+g);e=e.substr(f+1);e=new rb(e,h)}else throw Error("Bad token: "+z(a.a));a=new ac(uc(a),d.A);return c||
|
||||
new bc(d,e,a,"//"==b)}function uc(a){for(var b=[];"["==y(a.a);){z(a.a);N(a,"Missing predicate expression.");var c=lc(a);b.push(c);N(a,"Unclosed predicate expression.");nc(a,"]")}return b}function mc(a){if("-"==y(a.a))return z(a.a),new ic(mc(a));var b=sc(a);if("|"!=y(a.a))a=b;else{for(b=[b];"|"==z(a.a);)N(a,"Missing next union location path."),b.push(sc(a));a.a.a--;a=new jc(b)}return a};function vc(a){switch(a.nodeType){case 1:return la(wc,a);case 9:return vc(a.documentElement);case 11:case 10:case 6:case 12:return xc;default:return a.parentNode?vc(a.parentNode):xc}}function xc(){return null}function wc(a,b){if(a.prefix==b)return a.namespaceURI||"http://www.w3.org/1999/xhtml";var c=a.getAttributeNode("xmlns:"+b);return c&&c.specified?c.value||null:a.parentNode&&9!=a.parentNode.nodeType?wc(a.parentNode,b):null};function yc(a,b){if(!a.length)throw Error("Empty XPath expression.");a=Za(a);if(bb(a))throw Error("Invalid XPath expression.");b?ea(b)||(b=ka(b.lookupNamespaceURI,b)):b=function(){return null};var c=lc(new kc(a,b));if(!bb(a))throw Error("Bad token: "+z(a));this.evaluate=function(d,e){d=c.a(new ma(d));return new O(d,e)}}
|
||||
function O(a,b){if(0==b)if(a instanceof C)b=4;else if("string"==typeof a)b=2;else if("number"==typeof a)b=1;else if("boolean"==typeof a)b=3;else throw Error("Unexpected evaluation result.");if(2!=b&&1!=b&&3!=b&&!(a instanceof C))throw Error("value could not be converted to the specified type");this.resultType=b;switch(b){case 2:this.stringValue=a instanceof C?Bb(a):""+a;break;case 1:this.numberValue=a instanceof C?+Bb(a):+a;break;case 3:this.booleanValue=a instanceof C?0<a.m:!!a;break;case 4:case 5:case 6:case 7:var c=
|
||||
Cb(a);var d=[];for(var e=E(c);e;e=E(c))d.push(e instanceof Wa?e.a:e);this.snapshotLength=a.m;this.invalidIteratorState=!1;break;case 8:case 9:a=zb(a);this.singleNodeValue=a instanceof Wa?a.a:a;break;default:throw Error("Unknown XPathResult type.");}var f=0;this.iterateNext=function(){if(4!=b&&5!=b)throw Error("iterateNext called with wrong result type");return f>=d.length?null:d[f++]};this.snapshotItem=function(g){if(6!=b&&7!=b)throw Error("snapshotItem called with wrong result type");return g>=d.length||
|
||||
0>g?null:d[g]}}O.ANY_TYPE=0;O.NUMBER_TYPE=1;O.STRING_TYPE=2;O.BOOLEAN_TYPE=3;O.UNORDERED_NODE_ITERATOR_TYPE=4;O.ORDERED_NODE_ITERATOR_TYPE=5;O.UNORDERED_NODE_SNAPSHOT_TYPE=6;O.ORDERED_NODE_SNAPSHOT_TYPE=7;O.ANY_UNORDERED_NODE_TYPE=8;O.FIRST_ORDERED_NODE_TYPE=9;function zc(a){this.lookupNamespaceURI=vc(a)}
|
||||
function Ac(a,b){a=a||aa;var c=a.Document&&a.Document.prototype||a.document;if(!c.evaluate||b)a.XPathResult=O,c.evaluate=function(d,e,f,g){return(new yc(d,f)).evaluate(e,g)},c.createExpression=function(d,e){return new yc(d,e)},c.createNSResolver=function(d){return new zc(d)}}ca("wgxpath.install",Ac);ca("wgxpath.install",Ac);var Bc=window;function P(a,b){this.code=a;this.a=Q[a]||Cc;this.message=b||"";a=this.a.replace(/((?:^|\s+)[a-z])/g,function(c){return c.toUpperCase().replace(/^[\s\xa0]+/g,"")});b=a.length-5;if(0>b||a.indexOf("Error",b)!=b)a+="Error";this.name=a;a=Error(this.message);a.name=this.name;this.stack=a.stack||""}k(P,Error);var Cc="unknown error",Q={15:"element not selectable",11:"element not visible"};Q[31]=Cc;Q[30]=Cc;Q[24]="invalid cookie domain";Q[29]="invalid element coordinates";Q[12]="invalid element state";
|
||||
Q[32]="invalid selector";Q[51]="invalid selector";Q[52]="invalid selector";Q[17]="javascript error";Q[405]="unsupported operation";Q[34]="move target out of bounds";Q[27]="no such alert";Q[7]="no such element";Q[8]="no such frame";Q[23]="no such window";Q[28]="script timeout";Q[33]="session not created";Q[10]="stale element reference";Q[21]="timeout";Q[25]="unable to set cookie";Q[26]="unexpected alert open";Q[13]=Cc;Q[9]="unknown command";var Dc={C:function(a){return!(!a.querySelectorAll||!a.querySelector)},o:function(a,b){if(!a)throw new P(32,"No class name specified");a=Aa(a);if(-1!==a.indexOf(" "))throw new P(32,"Compound class names not permitted");if(Dc.C(b))try{return b.querySelector("."+a.replace(/\./g,"\\."))||null}catch(c){throw new P(32,"An invalid or illegal class name was specified");}a=mb(eb(b),"*",a,b);return a.length?a[0]:null},j:function(a,b){if(!a)throw new P(32,"No class name specified");a=Aa(a);if(-1!==a.indexOf(" "))throw new P(32,
|
||||
"Compound class names not permitted");if(Dc.C(b))try{return b.querySelectorAll("."+a.replace(/\./g,"\\."))}catch(c){throw new P(32,"An invalid or illegal class name was specified");}return mb(eb(b),"*",a,b)}};var Ec=Fa(),Fc=Ia()||r("iPod"),Gc=r("iPad"),Hc=r("Android")&&!(Ga()||Fa()||r("Opera")||r("Silk")),Ic=Ga(),Jc=r("Safari")&&!(Ga()||r("Coast")||r("Opera")||r("Edge")||r("Edg/")||r("OPR")||Fa()||r("Silk")||r("Android"))&&!(Ia()||r("iPad")||r("iPod"));function Kc(a){return(a=a.exec(q))?a[1]:""}(function(){if(Ec)return Kc(/Firefox\/([0-9.]+)/);if(t||Ma||La)return Qa;if(Ic)return Ia()||r("iPad")||r("iPod")?Kc(/CriOS\/([0-9.]+)/):Kc(/Chrome\/([0-9.]+)/);if(Jc&&!(Ia()||r("iPad")||r("iPod")))return Kc(/Version\/([0-9.]+)/);if(Fc||Gc){var a=/Version\/(\S+).*Mobile\/(\S+)/.exec(q);if(a)return a[1]+"."+a[2]}else if(Hc)return(a=Kc(/Android\s+([0-9.]+)/))?a:Kc(/Version\/([0-9.]+)/);return""})();var Lc=t&&!(8<=Number(w)),Mc=t&&!(9<=Number(w));var Nc={o:function(a,b){if(!ea(b.querySelector)&&t&&(t?0<=Ba(w,8):Ua(8))&&!ha(b.querySelector))throw Error("CSS selection is not supported");if(!a)throw new P(32,"No selector specified");a=Aa(a);try{var c=b.querySelector(a)}catch(d){throw new P(32,"An invalid or illegal selector was specified");}return c&&1==c.nodeType?c:null},j:function(a,b){if(!ea(b.querySelectorAll)&&t&&(t?0<=Ba(w,8):Ua(8))&&!ha(b.querySelector))throw Error("CSS selection is not supported");if(!a)throw new P(32,"No selector specified");
|
||||
a=Aa(a);try{return b.querySelectorAll(a)}catch(c){throw new P(32,"An invalid or illegal selector was specified");}}};var Oc={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",
|
||||
darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",
|
||||
ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",
|
||||
lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",
|
||||
moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",
|
||||
seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};var Pc="backgroundColor borderTopColor borderRightColor borderBottomColor borderLeftColor color outlineColor".split(" "),Qc=/#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/,Rc=/^#(?:[0-9a-f]{3}){1,2}$/i,Sc=/^(?:rgba)?\((\d{1,3}),\s?(\d{1,3}),\s?(\d{1,3}),\s?(0|1|0\.\d*)\)$/i,Tc=/^(?:rgb)?\((0|[1-9]\d{0,2}),\s?(0|[1-9]\d{0,2}),\s?(0|[1-9]\d{0,2})\)$/i;function Uc(a,b){b=b.toLowerCase();return"style"==b?Vc(a.style.cssText):Lc&&"value"==b&&S(a,"INPUT")?a.value:Mc&&!0===a[b]?String(a.getAttribute(b)):(a=a.getAttributeNode(b))&&a.specified?a.value:null}var Wc=/[;]+(?=(?:(?:[^"]*"){2})*[^"]*$)(?=(?:(?:[^']*'){2})*[^']*$)(?=(?:[^()]*\([^()]*\))*[^()]*$)/;
|
||||
function Vc(a){var b=[];l(a.split(Wc),function(c){var d=c.indexOf(":");0<d&&(c=[c.slice(0,d),c.slice(d+1)],2==c.length&&b.push(c[0].toLowerCase(),":",c[1],";"))});b=b.join("");return b=";"==b.charAt(b.length-1)?b:b+";"}function S(a,b){b&&"string"!==typeof b&&(b=b.toString());return a instanceof HTMLFormElement?!!a&&1==a.nodeType&&(!b||"FORM"==b):!!a&&1==a.nodeType&&(!b||a.tagName.toUpperCase()==b)};function Xc(a,b,c,d){this.c=a;this.a=b;this.b=c;this.f=d}Xc.prototype.ceil=function(){this.c=Math.ceil(this.c);this.a=Math.ceil(this.a);this.b=Math.ceil(this.b);this.f=Math.ceil(this.f);return this};Xc.prototype.floor=function(){this.c=Math.floor(this.c);this.a=Math.floor(this.a);this.b=Math.floor(this.b);this.f=Math.floor(this.f);return this};Xc.prototype.round=function(){this.c=Math.round(this.c);this.a=Math.round(this.a);this.b=Math.round(this.b);this.f=Math.round(this.f);return this};function T(a,b,c,d){this.a=a;this.b=b;this.width=c;this.height=d}T.prototype.ceil=function(){this.a=Math.ceil(this.a);this.b=Math.ceil(this.b);this.width=Math.ceil(this.width);this.height=Math.ceil(this.height);return this};T.prototype.floor=function(){this.a=Math.floor(this.a);this.b=Math.floor(this.b);this.width=Math.floor(this.width);this.height=Math.floor(this.height);return this};
|
||||
T.prototype.round=function(){this.a=Math.round(this.a);this.b=Math.round(this.b);this.width=Math.round(this.width);this.height=Math.round(this.height);return this};var Yc="function"===typeof ShadowRoot;function Zc(a){for(a=a.parentNode;a&&1!=a.nodeType&&9!=a.nodeType&&11!=a.nodeType;)a=a.parentNode;return S(a)?a:null}
|
||||
function U(a,b){b=Ha(b);if("float"==b||"cssFloat"==b||"styleFloat"==b)b=Mc?"styleFloat":"cssFloat";a:{var c=b;var d=A(a);if(d.defaultView&&d.defaultView.getComputedStyle&&(d=d.defaultView.getComputedStyle(a,null))){c=d[c]||d.getPropertyValue(c)||"";break a}c=""}a=c||$c(a,b);if(null===a)a=null;else if(0<=oa(Pc,b)){b:{var e=a.match(Sc);if(e&&(b=Number(e[1]),c=Number(e[2]),d=Number(e[3]),e=Number(e[4]),0<=b&&255>=b&&0<=c&&255>=c&&0<=d&&255>=d&&0<=e&&1>=e)){b=[b,c,d,e];break b}b=null}if(!b)b:{if(d=a.match(Tc))if(b=
|
||||
Number(d[1]),c=Number(d[2]),d=Number(d[3]),0<=b&&255>=b&&0<=c&&255>=c&&0<=d&&255>=d){b=[b,c,d,1];break b}b=null}if(!b)b:{b=a.toLowerCase();c=Oc[b.toLowerCase()];if(!c&&(c="#"==b.charAt(0)?b:"#"+b,4==c.length&&(c=c.replace(Qc,"#$1$1$2$2$3$3")),!Rc.test(c))){b=null;break b}b=[parseInt(c.substr(1,2),16),parseInt(c.substr(3,2),16),parseInt(c.substr(5,2),16),1]}a=b?"rgba("+b.join(", ")+")":a}return a}
|
||||
function $c(a,b){var c=a.currentStyle||a.style,d=c[b];void 0===d&&ea(c.getPropertyValue)&&(d=c.getPropertyValue(b));return"inherit"!=d?void 0!==d?d:null:(a=Zc(a))?$c(a,b):null}
|
||||
function ad(a,b,c){function d(g){var h=V(g);return 0<h.height&&0<h.width?!0:S(g,"PATH")&&(0<h.height||0<h.width)?(g=U(g,"stroke-width"),!!g&&0<parseInt(g,10)):"hidden"!=U(g,"overflow")&&sa(g.childNodes,function(n){return 3==n.nodeType||S(n)&&d(n)})}function e(g){return bd(g)==W&&ta(g.childNodes,function(h){return!S(h)||e(h)||!d(h)})}if(!S(a))throw Error("Argument to isShown must be of type Element");if(S(a,"BODY"))return!0;if(S(a,"OPTION")||S(a,"OPTGROUP"))return a=lb(a,function(g){return S(g,"SELECT")}),
|
||||
!!a&&ad(a,!0,c);var f=cd(a);if(f)return!!f.image&&0<f.rect.width&&0<f.rect.height&&ad(f.image,b,c);if(S(a,"INPUT")&&"hidden"==a.type.toLowerCase()||S(a,"NOSCRIPT"))return!1;f=U(a,"visibility");return"collapse"!=f&&"hidden"!=f&&c(a)&&(b||0!=dd(a))&&d(a)?!e(a):!1}
|
||||
function ed(a){function b(c){if(S(c)&&"none"==U(c,"display"))return!1;var d;if((d=c.parentNode)&&d.shadowRoot&&void 0!==c.assignedSlot)d=c.assignedSlot?c.assignedSlot.parentNode:null;else if(c.getDestinationInsertionPoints){var e=c.getDestinationInsertionPoints();0<e.length&&(d=e[e.length-1])}if(Yc&&d instanceof ShadowRoot){if(d.host.shadowRoot&&d.host.shadowRoot!==d)return!1;d=d.host}return!d||9!=d.nodeType&&11!=d.nodeType?d&&S(d,"DETAILS")&&!d.open&&!S(c,"SUMMARY")?!1:!!d&&b(d):!0}return ad(a,!1,
|
||||
b)}var W="hidden";
|
||||
function bd(a){function b(m){function v(Ab){if(Ab==g)return!0;var pc=U(Ab,"display");return 0==pc.lastIndexOf("inline",0)||"contents"==pc||"absolute"==qc&&"static"==U(Ab,"position")?!1:!0}var qc=U(m,"position");if("fixed"==qc)return u=!0,m==g?null:g;for(m=Zc(m);m&&!v(m);)m=Zc(m);return m}function c(m){var v=m;if("visible"==n)if(m==g&&h)v=h;else if(m==h)return{x:"visible",y:"visible"};v={x:U(v,"overflow-x"),y:U(v,"overflow-y")};m==g&&(v.x="visible"==v.x?"auto":v.x,v.y="visible"==v.y?"auto":v.y);return v}
|
||||
function d(m){if(m==g){var v=(new fb(f)).a;m=v.scrollingElement?v.scrollingElement:Oa||"CSS1Compat"!=v.compatMode?v.body||v.documentElement:v.documentElement;v=v.parentWindow||v.defaultView;m=t&&Ua("10")&&v.pageYOffset!=m.scrollTop?new cb(m.scrollLeft,m.scrollTop):new cb(v.pageXOffset||m.scrollLeft,v.pageYOffset||m.scrollTop)}else m=new cb(m.scrollLeft,m.scrollTop);return m}var e=fd(a),f=A(a),g=f.documentElement,h=f.body,n=U(g,"overflow"),u;for(a=b(a);a;a=b(a)){var p=c(a);if("visible"!=p.x||"visible"!=
|
||||
p.y){var G=V(a);if(0==G.width||0==G.height)return W;var R=e.a<G.a,fa=e.b<G.b;if(R&&"hidden"==p.x||fa&&"hidden"==p.y)return W;if(R&&"visible"!=p.x||fa&&"visible"!=p.y){R=d(a);fa=e.b<G.b-R.y;if(e.a<G.a-R.x&&"visible"!=p.x||fa&&"visible"!=p.x)return W;e=bd(a);return e==W?W:"scroll"}R=e.f>=G.a+G.width;G=e.c>=G.b+G.height;if(R&&"hidden"==p.x||G&&"hidden"==p.y)return W;if(R&&"visible"!=p.x||G&&"visible"!=p.y){if(u&&(p=d(a),e.f>=g.scrollWidth-p.x||e.a>=g.scrollHeight-p.y))return W;e=bd(a);return e==W?W:
|
||||
"scroll"}}}return"none"}
|
||||
function V(a){var b=cd(a);if(b)return b.rect;if(S(a,"HTML"))return a=A(a),a=((a?a.parentWindow||a.defaultView:window)||window).document,a="CSS1Compat"==a.compatMode?a.documentElement:a.body,a=new db(a.clientWidth,a.clientHeight),new T(0,0,a.width,a.height);try{var c=a.getBoundingClientRect()}catch(d){return new T(0,0,0,0)}b=new T(c.left,c.top,c.right-c.left,c.bottom-c.top);t&&a.ownerDocument.body&&(a=A(a),b.a-=a.documentElement.clientLeft+a.body.clientLeft,b.b-=a.documentElement.clientTop+a.body.clientTop);
|
||||
return b}function cd(a){var b=S(a,"MAP");if(!b&&!S(a,"AREA"))return null;var c=b?a:S(a.parentNode,"MAP")?a.parentNode:null,d=null,e=null;c&&c.name&&(d=Nc.o('*[usemap="#'+c.name+'"]',A(c)))&&(e=V(d),b||"default"==a.shape.toLowerCase()||(a=gd(a),b=Math.min(Math.max(a.a,0),e.width),c=Math.min(Math.max(a.b,0),e.height),e=new T(b+e.a,c+e.b,Math.min(a.width,e.width-b),Math.min(a.height,e.height-c))));return{image:d,rect:e||new T(0,0,0,0)}}
|
||||
function gd(a){var b=a.shape.toLowerCase();a=a.coords.split(",");if("rect"==b&&4==a.length){b=a[0];var c=a[1];return new T(b,c,a[2]-b,a[3]-c)}if("circle"==b&&3==a.length)return b=a[2],new T(a[0]-b,a[1]-b,2*b,2*b);if("poly"==b&&2<a.length){b=a[0];c=a[1];for(var d=b,e=c,f=2;f+1<a.length;f+=2)b=Math.min(b,a[f]),d=Math.max(d,a[f]),c=Math.min(c,a[f+1]),e=Math.max(e,a[f+1]);return new T(b,c,d-b,e-c)}return new T(0,0,0,0)}function fd(a){a=V(a);return new Xc(a.b,a.a+a.width,a.b+a.height,a.a)}
|
||||
function hd(a){return a.replace(/^[^\S\xa0]+|[^\S\xa0]+$/g,"")}function id(a){var b=[];Yc?jd(a,b):kd(a,b);a=qa(b,hd);return hd(a.join("\n")).replace(/\xa0/g," ")}
|
||||
function ld(a,b,c){if(S(a,"BR"))b.push("");else{var d=S(a,"TD"),e=U(a,"display"),f=!d&&!(0<=oa(md,e)),g=void 0!==a.previousElementSibling?a.previousElementSibling:gb(a.previousSibling);g=g?U(g,"display"):"";var h=U(a,"float")||U(a,"cssFloat")||U(a,"styleFloat");!f||"run-in"==g&&"none"==h||/^[\s\xa0]*$/.test(b[b.length-1]||"")||b.push("");var n=ed(a),u=null,p=null;n&&(u=U(a,"white-space"),p=U(a,"text-transform"));l(a.childNodes,function(G){c(G,b,n,u,p)});a=b[b.length-1]||"";!d&&"table-cell"!=e||!a||
|
||||
za(a)||(b[b.length-1]+=" ");f&&"run-in"!=e&&!/^[\s\xa0]*$/.test(a)&&b.push("")}}function kd(a,b){ld(a,b,function(c,d,e,f,g){3==c.nodeType&&e?nd(c,d,f,g):S(c)&&kd(c,d)})}var md="inline inline-block inline-table none table-cell table-column table-column-group".split(" ");
|
||||
function nd(a,b,c,d){a=a.nodeValue.replace(/[\u200b\u200e\u200f]/g,"");a=a.replace(/(\r\n|\r|\n)/g,"\n");if("normal"==c||"nowrap"==c)a=a.replace(/\n/g," ");a="pre"==c||"pre-wrap"==c?a.replace(/[ \f\t\v\u2028\u2029]/g,"\u00a0"):a.replace(/[ \f\t\v\u2028\u2029]+/g," ");"capitalize"==d?a=a.replace(t?/(^|\s|\b)(\S)/g:/(^|\s|\b)(\S)/gu,function(e,f,g){return f+g.toUpperCase()}):"uppercase"==d?a=a.toUpperCase():"lowercase"==d&&(a=a.toLowerCase());c=b.pop()||"";za(c)&&0==a.lastIndexOf(" ",0)&&(a=a.substr(1));
|
||||
b.push(c+a)}function dd(a){if(Mc){if("relative"==U(a,"position"))return 1;a=U(a,"filter");return(a=a.match(/^alpha\(opacity=(\d*)\)/)||a.match(/^progid:DXImageTransform.Microsoft.Alpha\(Opacity=(\d*)\)/))?Number(a[1])/100:1}return od(a)}function od(a){var b=1,c=U(a,"opacity");c&&(b=Number(c));(a=Zc(a))&&(b*=od(a));return b}
|
||||
function pd(a,b,c,d,e){if(3==a.nodeType&&c)nd(a,b,d,e);else if(S(a))if(S(a,"CONTENT")||S(a,"SLOT")){for(var f=a;f.parentNode;)f=f.parentNode;f instanceof ShadowRoot?(f=S(a,"CONTENT")?a.getDistributedNodes():a.assignedNodes(),l(0<f.length?f:a.childNodes,function(g){pd(g,b,c,d,e)})):jd(a,b)}else if(S(a,"SHADOW")){for(f=a;f.parentNode;)f=f.parentNode;if(f instanceof ShadowRoot&&(a=f))for(a=a.olderShadowRoot;a;)l(a.childNodes,function(g){pd(g,b,c,d,e)}),a=a.olderShadowRoot}else jd(a,b)}
|
||||
function jd(a,b){a.shadowRoot&&l(a.shadowRoot.childNodes,function(c){pd(c,b,!0,null,null)});ld(a,b,function(c,d,e,f,g){var h=null;1==c.nodeType?h=c:3==c.nodeType&&(h=c);null!=h&&(null!=h.assignedSlot||h.getDestinationInsertionPoints&&0<h.getDestinationInsertionPoints().length)||pd(c,d,e,f,g)})};var qd={C:function(a,b){return!(!a.querySelectorAll||!a.querySelector)&&!/^\d.*/.test(b)},o:function(a,b){var c=eb(b),d="string"===typeof a?c.a.getElementById(a):a;return d?Uc(d,"id")==a&&b!=d&&hb(b,d)?d:ua(mb(c,"*"),function(e){return Uc(e,"id")==a&&b!=e&&hb(b,e)}):null},j:function(a,b){if(!a)return[];if(qd.C(b,a))try{return b.querySelectorAll("#"+qd.T(a))}catch(c){return[]}b=mb(eb(b),"*",null,b);return pa(b,function(c){return Uc(c,"id")==a})},T:function(a){return a.replace(/([\s'"\\#.:;,!?+<>=~*^$|%&@`{}\-\/\[\]\(\)])/g,
|
||||
"\\$1")}};var X={},rd={};X.N=function(a,b,c){try{var d=Nc.j("a",b)}catch(e){d=mb(eb(b),"A",null,b)}return ua(d,function(e){e=id(e);e=e.replace(/^[\s]+|[\s]+$/g,"");return c&&-1!=e.indexOf(a)||e==a})};X.K=function(a,b,c){try{var d=Nc.j("a",b)}catch(e){d=mb(eb(b),"A",null,b)}return pa(d,function(e){e=id(e);e=e.replace(/^[\s]+|[\s]+$/g,"");return c&&-1!=e.indexOf(a)||e==a})};X.o=function(a,b){return X.N(a,b,!1)};X.j=function(a,b){return X.K(a,b,!1)};rd.o=function(a,b){return X.N(a,b,!0)};
|
||||
rd.j=function(a,b){return X.K(a,b,!0)};var Y={F:function(a,b){return function(c){var d=Y.u(a);d=V(d);c=V(c);return b.call(null,d,c)}},R:function(a){return Y.F(a,function(b,c){return c.b+c.height<b.b})},S:function(a){return Y.F(a,function(b,c){return b.b+b.height<c.b})},V:function(a){return Y.F(a,function(b,c){return c.a+c.width<b.a})},aa:function(a){return Y.F(a,function(b,c){return b.a+b.width<c.a})},W:function(a,b){var c;b?c=b:"number"==typeof a.distance&&(c=a.distance);c||(c=50);return function(d){var e=Y.u(a);if(e===d)return!1;e=V(e);
|
||||
d=V(d);e=new T(e.a-c,e.b-c,e.width+2*c,e.height+2*c);return e.a<=d.a+d.width&&d.a<=e.a+e.width&&e.b<=d.b+d.height&&d.b<=e.b+e.height}},u:function(a){if(ha(a)&&1==a.nodeType)return a;if(ea(a))return Y.u(a.call(null));if(ha(a)){var b;a:{if(b=sd(a)){var c=td[b];if(c&&ea(c.o)){b=c.o(a[b],Bc.document);break a}}throw new P(61,"Unsupported locator strategy: "+b);}if(!b)throw new P(7,"No element has been found by "+JSON.stringify(a));return b}throw new P(61,"Selector is of wrong type: "+JSON.stringify(a));
|
||||
}};Y.P={left:Y.V,right:Y.aa,above:Y.R,below:Y.S,near:Y.W};Y.O={left:Y.u,right:Y.u,above:Y.u,below:Y.u,near:Y.u};Y.U=function(a,b){var c=[];l(a,function(e){e&&ta(b,function(f){var g=f.kind,h=Y.P[g];if(!h)throw new P(61,"Cannot find filter suitable for "+g);return h.apply(null,f.args)(e)},null)&&c.push(e)},null);a=b[b.length-1];var d=Y.O[a?a.kind:"unknown"];return d?(a=d.apply(null,a.args))?Y.ba(a,c):c:c};
|
||||
Y.ba=function(a,b){function c(f){f=V(f);return Math.sqrt(Math.pow(d-(f.a+Math.max(1,f.width)/2),2)+Math.pow(e-(f.b+Math.max(1,f.height)/2),2))}a=V(a);var d=a.a+Math.max(1,a.width)/2,e=a.b+Math.max(1,a.height)/2;xa(b,function(f,g){return c(f)-c(g)});return b};Y.o=function(a,b){a=Y.j(a,b);return 0==a.length?null:a[0]};
|
||||
Y.j=function(a,b){if(!a.hasOwnProperty("root")||!a.hasOwnProperty("filters"))throw new P(61,"Locator not suitable for relative locators: "+JSON.stringify(a));var c=a.filters,d=da(c);if("array"!=d&&("object"!=d||"number"!=typeof c.length))throw new P(61,"Targets should be an array: "+JSON.stringify(a));var e;S(a.root)?e=[a.root]:e=ud(a.root,b);return 0==e.length?[]:Y.U(e,a.filters)};var vd={o:function(a,b){if(""===a)throw new P(32,'Unable to locate an element with the tagName ""');return b.getElementsByTagName(a)[0]||null},j:function(a,b){if(""===a)throw new P(32,'Unable to locate an element with the tagName ""');return b.getElementsByTagName(a)}};var Z={};Z.I=function(){var a={da:"http://www.w3.org/2000/svg"};return function(b){return a[b]||null}}();
|
||||
Z.s=function(a,b,c){var d=A(a);if(!d.documentElement)return null;(t||Hc)&&Ac(d?d.parentWindow||d.defaultView:window);try{var e=d.createNSResolver?d.createNSResolver(d.documentElement):Z.I;if(t&&!Ua(7))return d.evaluate.call(d,b,a,e,c,null);if(!t||9<=Number(w)){for(var f={},g=d.getElementsByTagName("*"),h=0;h<g.length;++h){var n=g[h],u=n.namespaceURI;if(u&&!f[u]){var p=n.lookupPrefix(u);if(!p){var G=u.match(".*/(\\w+)/?$");p=G?G[1]:"xhtml"}f[u]=p}}var R={},fa;for(fa in f)R[f[fa]]=fa;e=function(m){return R[m]||
|
||||
null}}try{return d.evaluate(b,a,e,c,null)}catch(m){if("TypeError"===m.name)return e=d.createNSResolver?d.createNSResolver(d.documentElement):Z.I,d.evaluate(b,a,e,c,null);throw m;}}catch(m){if(!Na||"NS_ERROR_ILLEGAL_VALUE"!=m.name)throw new P(32,"Unable to locate an element with the xpath expression "+b+" because of the following error:\n"+m);}};Z.J=function(a,b){if(!a||1!=a.nodeType)throw new P(32,'The result of the xpath expression "'+b+'" is: '+a+". It should be an element.");};
|
||||
Z.o=function(a,b){var c=function(){var d=Z.s(b,a,9);return d?d.singleNodeValue||null:b.selectSingleNode?(d=A(b),d.setProperty&&d.setProperty("SelectionLanguage","XPath"),b.selectSingleNode(a)):null}();null===c||Z.J(c,a);return c};
|
||||
Z.j=function(a,b){var c=function(){var d=Z.s(b,a,7);if(d){for(var e=d.snapshotLength,f=[],g=0;g<e;++g)f.push(d.snapshotItem(g));return f}return b.selectNodes?(d=A(b),d.setProperty&&d.setProperty("SelectionLanguage","XPath"),b.selectNodes(a)):[]}();l(c,function(d){Z.J(d,a)});return c};var td={className:Dc,"class name":Dc,css:Nc,"css selector":Nc,relative:Y,id:qd,linkText:X,"link text":X,name:{o:function(a,b){b=mb(eb(b),"*",null,b);return ua(b,function(c){return Uc(c,"name")==a})},j:function(a,b){b=mb(eb(b),"*",null,b);return pa(b,function(c){return Uc(c,"name")==a})}},partialLinkText:rd,"partial link text":rd,tagName:vd,"tag name":vd,xpath:Z};function sd(a){for(var b in a)if(a.hasOwnProperty(b))return b;return null}
|
||||
function ud(a,b){var c=sd(a);if(c){var d=td[c];if(d&&ea(d.j))return d.j(a[c],b||Bc.document)}throw new P(61,"Unsupported locator strategy: "+c);};ca("_",ud);; return this._.apply(null,arguments);}).apply({navigator:typeof window!='undefined'?window.navigator:null,document:typeof window!='undefined'?window.document:null}, arguments);}
|
6
lib/python3.13/site-packages/selenium/webdriver/remote/getAttribute.js
Executable file
6
lib/python3.13/site-packages/selenium/webdriver/remote/getAttribute.js
Executable file
@ -0,0 +1,6 @@
|
||||
function(){return (function(){var d=this||self;function f(a,b){function c(){}c.prototype=b.prototype;a.prototype=new c;a.prototype.constructor=a};var h=Array.prototype.indexOf?function(a,b){return Array.prototype.indexOf.call(a,b,void 0)}:function(a,b){if("string"===typeof a)return"string"!==typeof b||1!=b.length?-1:a.indexOf(b,0);for(var c=0;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1},k=Array.prototype.forEach?function(a,b){Array.prototype.forEach.call(a,b,void 0)}:function(a,b){for(var c=a.length,e="string"===typeof a?a.split(""):a,g=0;g<c;g++)g in e&&b.call(void 0,e[g],g,a)};function l(a,b){this.code=a;this.a=m[a]||n;this.message=b||"";a=this.a.replace(/((?:^|\s+)[a-z])/g,function(c){return c.toUpperCase().replace(/^[\s\xa0]+/g,"")});b=a.length-5;if(0>b||a.indexOf("Error",b)!=b)a+="Error";this.name=a;a=Error(this.message);a.name=this.name;this.stack=a.stack||""}f(l,Error);var n="unknown error",m={15:"element not selectable",11:"element not visible"};m[31]=n;m[30]=n;m[24]="invalid cookie domain";m[29]="invalid element coordinates";m[12]="invalid element state";m[32]="invalid selector";
|
||||
m[51]="invalid selector";m[52]="invalid selector";m[17]="javascript error";m[405]="unsupported operation";m[34]="move target out of bounds";m[27]="no such alert";m[7]="no such element";m[8]="no such frame";m[23]="no such window";m[28]="script timeout";m[33]="session not created";m[10]="stale element reference";m[21]="timeout";m[25]="unable to set cookie";m[26]="unexpected alert open";m[13]=n;m[9]="unknown command";var p;a:{var q=d.navigator;if(q){var r=q.userAgent;if(r){p=r;break a}}p=""}function t(a){return-1!=p.indexOf(a)};function u(){return t("Firefox")||t("FxiOS")}function v(){return(t("Chrome")||t("CriOS"))&&!t("Edge")};function w(){return t("iPhone")&&!t("iPod")&&!t("iPad")};var y=t("Opera"),z=t("Trident")||t("MSIE"),A=t("Edge"),B=t("Gecko")&&!(-1!=p.toLowerCase().indexOf("webkit")&&!t("Edge"))&&!(t("Trident")||t("MSIE"))&&!t("Edge"),C=-1!=p.toLowerCase().indexOf("webkit")&&!t("Edge");function D(){var a=d.document;return a?a.documentMode:void 0}var E;
|
||||
a:{var F="",G=function(){var a=p;if(B)return/rv:([^\);]+)(\)|;)/.exec(a);if(A)return/Edge\/([\d\.]+)/.exec(a);if(z)return/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(a);if(C)return/WebKit\/(\S+)/.exec(a);if(y)return/(?:Version)[ \/]?(\S+)/.exec(a)}();G&&(F=G?G[1]:"");if(z){var H=D();if(null!=H&&H>parseFloat(F)){E=String(H);break a}}E=F}var I;I=d.document&&z?D():void 0;var J=u(),K=w()||t("iPod"),L=t("iPad"),M=t("Android")&&!(v()||u()||t("Opera")||t("Silk")),N=v(),aa=t("Safari")&&!(v()||t("Coast")||t("Opera")||t("Edge")||t("Edg/")||t("OPR")||u()||t("Silk")||t("Android"))&&!(w()||t("iPad")||t("iPod"));function O(a){return(a=a.exec(p))?a[1]:""}(function(){if(J)return O(/Firefox\/([0-9.]+)/);if(z||A||y)return E;if(N)return w()||t("iPad")||t("iPod")?O(/CriOS\/([0-9.]+)/):O(/Chrome\/([0-9.]+)/);if(aa&&!(w()||t("iPad")||t("iPod")))return O(/Version\/([0-9.]+)/);if(K||L){var a=/Version\/(\S+).*Mobile\/(\S+)/.exec(p);if(a)return a[1]+"."+a[2]}else if(M)return(a=O(/Android\s+([0-9.]+)/))?a:O(/Version\/([0-9.]+)/);return""})();var P=z&&!(8<=Number(I)),ba=z&&!(9<=Number(I));var ca={SCRIPT:1,STYLE:1,HEAD:1,IFRAME:1,OBJECT:1},Q={IMG:" ",BR:"\n"};function R(a,b,c){if(!(a.nodeName in ca))if(3==a.nodeType)c?b.push(String(a.nodeValue).replace(/(\r\n|\r|\n)/g,"")):b.push(a.nodeValue);else if(a.nodeName in Q)b.push(Q[a.nodeName]);else for(a=a.firstChild;a;)R(a,b,c),a=a.nextSibling};function S(a,b){b=b.toLowerCase();return"style"==b?da(a.style.cssText):P&&"value"==b&&T(a,"INPUT")?a.value:ba&&!0===a[b]?String(a.getAttribute(b)):(a=a.getAttributeNode(b))&&a.specified?a.value:null}var ea=/[;]+(?=(?:(?:[^"]*"){2})*[^"]*$)(?=(?:(?:[^']*'){2})*[^']*$)(?=(?:[^()]*\([^()]*\))*[^()]*$)/;
|
||||
function da(a){var b=[];k(a.split(ea),function(c){var e=c.indexOf(":");0<e&&(c=[c.slice(0,e),c.slice(e+1)],2==c.length&&b.push(c[0].toLowerCase(),":",c[1],";"))});b=b.join("");return b=";"==b.charAt(b.length-1)?b:b+";"}function U(a,b){P&&"value"==b&&T(a,"OPTION")&&null===S(a,"value")?(b=[],R(a,b,!1),a=b.join("")):a=a[b];return a}
|
||||
function T(a,b){b&&"string"!==typeof b&&(b=b.toString());return a instanceof HTMLFormElement?!!a&&1==a.nodeType&&(!b||"FORM"==b):!!a&&1==a.nodeType&&(!b||a.tagName.toUpperCase()==b)}function V(a){return T(a,"OPTION")?!0:T(a,"INPUT")?(a=a.type.toLowerCase(),"checkbox"==a||"radio"==a):!1};var fa={"class":"className",readonly:"readOnly"},ha="allowfullscreen allowpaymentrequest allowusermedia async autofocus autoplay checked compact complete controls declare default defaultchecked defaultselected defer disabled ended formnovalidate hidden indeterminate iscontenteditable ismap itemscope loop multiple muted nohref nomodule noresize noshade novalidate nowrap open paused playsinline pubdate readonly required reversed scoped seamless seeking selected truespeed typemustmatch willvalidate".split(" ");function W(a,b){var c=null,e=b.toLowerCase();if("style"==e)return(c=a.style)&&"string"!=typeof c&&(c=c.cssText),c;if(("selected"==e||"checked"==e)&&V(a)){if(!V(a))throw new l(15,"Element is not selectable");b="selected";c=a.type&&a.type.toLowerCase();if("checkbox"==c||"radio"==c)b="checked";return U(a,b)?"true":null}var g=T(a,"A");if(T(a,"IMG")&&"src"==e||g&&"href"==e)return(c=S(a,e))&&(c=U(a,e)),c;if("spellcheck"==e){c=S(a,e);if(null!==c){if("false"==c.toLowerCase())return"false";if("true"==c.toLowerCase())return"true"}return U(a,
|
||||
e)+""}g=fa[b]||b;if(0<=h(ha,e))return(c=null!==S(a,b)||U(a,g))?"true":null;try{var x=U(a,g)}catch(ia){}(e=null==x)||(e=typeof x,e="object"==e&&null!=x||"function"==e);e?c=S(a,b):c=x;return null!=c?c.toString():null}var X=["_"],Y=d;X[0]in Y||"undefined"==typeof Y.execScript||Y.execScript("var "+X[0]);for(var Z;X.length&&(Z=X.shift());)X.length||void 0===W?Y[Z]&&Y[Z]!==Object.prototype[Z]?Y=Y[Z]:Y=Y[Z]={}:Y[Z]=W;; return this._.apply(null,arguments);}).apply({navigator:typeof window!='undefined'?window.navigator:null,document:typeof window!='undefined'?window.document:null}, arguments);}
|
28
lib/python3.13/site-packages/selenium/webdriver/remote/isDisplayed.js
Executable file
28
lib/python3.13/site-packages/selenium/webdriver/remote/isDisplayed.js
Executable file
@ -0,0 +1,28 @@
|
||||
function(){return (function(){var g=this||self;
|
||||
function aa(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";else if("function"==
|
||||
b&&"undefined"==typeof a.call)return"object";return b}function ca(a,b){function c(){}c.prototype=b.prototype;a.prototype=new c;a.prototype.constructor=a};var da=Array.prototype.indexOf?function(a,b){return Array.prototype.indexOf.call(a,b,void 0)}:function(a,b){if("string"===typeof a)return"string"!==typeof b||1!=b.length?-1:a.indexOf(b,0);for(var c=0;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1},ea=Array.prototype.some?function(a,b){return Array.prototype.some.call(a,b,void 0)}:function(a,b){for(var c=a.length,e="string"===typeof a?a.split(""):a,d=0;d<c;d++)if(d in e&&b.call(void 0,e[d],d,a))return!0;return!1},fa=Array.prototype.every?function(a,
|
||||
b){return Array.prototype.every.call(a,b,void 0)}:function(a,b){for(var c=a.length,e="string"===typeof a?a.split(""):a,d=0;d<c;d++)if(d in e&&!b.call(void 0,e[d],d,a))return!1;return!0};var ha={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",
|
||||
darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",
|
||||
ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",
|
||||
lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",
|
||||
moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",
|
||||
seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};var ia="backgroundColor borderTopColor borderRightColor borderBottomColor borderLeftColor color outlineColor".split(" "),ja=/#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/,ka=/^#(?:[0-9a-f]{3}){1,2}$/i,la=/^(?:rgba)?\((\d{1,3}),\s?(\d{1,3}),\s?(\d{1,3}),\s?(0|1|0\.\d*)\)$/i,ma=/^(?:rgb)?\((0|[1-9]\d{0,2}),\s?(0|[1-9]\d{0,2}),\s?(0|[1-9]\d{0,2})\)$/i;function m(a,b){this.code=a;this.a=p[a]||r;this.message=b||"";a=this.a.replace(/((?:^|\s+)[a-z])/g,function(c){return c.toUpperCase().replace(/^[\s\xa0]+/g,"")});b=a.length-5;if(0>b||a.indexOf("Error",b)!=b)a+="Error";this.name=a;a=Error(this.message);a.name=this.name;this.stack=a.stack||""}ca(m,Error);var r="unknown error",p={15:"element not selectable",11:"element not visible"};p[31]=r;p[30]=r;p[24]="invalid cookie domain";p[29]="invalid element coordinates";p[12]="invalid element state";
|
||||
p[32]="invalid selector";p[51]="invalid selector";p[52]="invalid selector";p[17]="javascript error";p[405]="unsupported operation";p[34]="move target out of bounds";p[27]="no such alert";p[7]="no such element";p[8]="no such frame";p[23]="no such window";p[28]="script timeout";p[33]="session not created";p[10]="stale element reference";p[21]="timeout";p[25]="unable to set cookie";p[26]="unexpected alert open";p[13]=r;p[9]="unknown command";var u=String.prototype.trim?function(a){return a.trim()}:function(a){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(a)[1]};
|
||||
function na(a,b){var c=0;a=u(String(a)).split(".");b=u(String(b)).split(".");for(var e=Math.max(a.length,b.length),d=0;0==c&&d<e;d++){var f=a[d]||"",h=b[d]||"";do{f=/(\d*)(\D*)(.*)/.exec(f)||["","","",""];h=/(\d*)(\D*)(.*)/.exec(h)||["","","",""];if(0==f[0].length&&0==h[0].length)break;c=v(0==f[1].length?0:parseInt(f[1],10),0==h[1].length?0:parseInt(h[1],10))||v(0==f[2].length,0==h[2].length)||v(f[2],h[2]);f=f[3];h=h[3]}while(0==c)}return c}function v(a,b){return a<b?-1:a>b?1:0};var w;a:{var oa=g.navigator;if(oa){var sa=oa.userAgent;if(sa){w=sa;break a}}w=""}function x(a){return-1!=w.indexOf(a)};function y(){return x("Firefox")||x("FxiOS")}function A(){return(x("Chrome")||x("CriOS"))&&!x("Edge")};function ta(a){return String(a).replace(/\-([a-z])/g,function(b,c){return c.toUpperCase()})};function B(){return x("iPhone")&&!x("iPod")&&!x("iPad")};function ua(a,b){var c=va;return Object.prototype.hasOwnProperty.call(c,a)?c[a]:c[a]=b(a)};var wa=x("Opera"),C=x("Trident")||x("MSIE"),xa=x("Edge"),ya=x("Gecko")&&!(-1!=w.toLowerCase().indexOf("webkit")&&!x("Edge"))&&!(x("Trident")||x("MSIE"))&&!x("Edge"),za=-1!=w.toLowerCase().indexOf("webkit")&&!x("Edge");function Aa(){var a=g.document;return a?a.documentMode:void 0}var E;
|
||||
a:{var F="",G=function(){var a=w;if(ya)return/rv:([^\);]+)(\)|;)/.exec(a);if(xa)return/Edge\/([\d\.]+)/.exec(a);if(C)return/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(a);if(za)return/WebKit\/(\S+)/.exec(a);if(wa)return/(?:Version)[ \/]?(\S+)/.exec(a)}();G&&(F=G?G[1]:"");if(C){var H=Aa();if(null!=H&&H>parseFloat(F)){E=String(H);break a}}E=F}var va={};function Ba(a){return ua(a,function(){return 0<=na(E,a)})}var I;I=g.document&&C?Aa():void 0;var Ca=y(),Da=B()||x("iPod"),Ea=x("iPad"),Fa=x("Android")&&!(A()||y()||x("Opera")||x("Silk")),Ga=A(),Ha=x("Safari")&&!(A()||x("Coast")||x("Opera")||x("Edge")||x("Edg/")||x("OPR")||y()||x("Silk")||x("Android"))&&!(B()||x("iPad")||x("iPod"));function J(a){return(a=a.exec(w))?a[1]:""}(function(){if(Ca)return J(/Firefox\/([0-9.]+)/);if(C||xa||wa)return E;if(Ga)return B()||x("iPad")||x("iPod")?J(/CriOS\/([0-9.]+)/):J(/Chrome\/([0-9.]+)/);if(Ha&&!(B()||x("iPad")||x("iPod")))return J(/Version\/([0-9.]+)/);if(Da||Ea){var a=/Version\/(\S+).*Mobile\/(\S+)/.exec(w);if(a)return a[1]+"."+a[2]}else if(Fa)return(a=J(/Android\s+([0-9.]+)/))?a:J(/Version\/([0-9.]+)/);return""})();var K;if(K=C)K=!(9<=Number(I));var Ia=K;function L(a,b){this.x=void 0!==a?a:0;this.y=void 0!==b?b:0}L.prototype.ceil=function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this};L.prototype.floor=function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);return this};L.prototype.round=function(){this.x=Math.round(this.x);this.y=Math.round(this.y);return this};function M(a,b){this.width=a;this.height=b}M.prototype.aspectRatio=function(){return this.width/this.height};M.prototype.ceil=function(){this.width=Math.ceil(this.width);this.height=Math.ceil(this.height);return this};M.prototype.floor=function(){this.width=Math.floor(this.width);this.height=Math.floor(this.height);return this};M.prototype.round=function(){this.width=Math.round(this.width);this.height=Math.round(this.height);return this};function N(a){return 9==a.nodeType?a:a.ownerDocument||a.document}function Ja(a,b){a&&(a=a.parentNode);for(var c=0;a;){if(b(a))return a;a=a.parentNode;c++}return null}function Ka(a){this.a=a||g.document||document};function P(a,b){b&&"string"!==typeof b&&(b=b.toString());return a instanceof HTMLFormElement?!!a&&1==a.nodeType&&(!b||"FORM"==b):!!a&&1==a.nodeType&&(!b||a.tagName.toUpperCase()==b)};function Q(a,b,c,e){this.f=a;this.a=b;this.b=c;this.c=e}Q.prototype.ceil=function(){this.f=Math.ceil(this.f);this.a=Math.ceil(this.a);this.b=Math.ceil(this.b);this.c=Math.ceil(this.c);return this};Q.prototype.floor=function(){this.f=Math.floor(this.f);this.a=Math.floor(this.a);this.b=Math.floor(this.b);this.c=Math.floor(this.c);return this};Q.prototype.round=function(){this.f=Math.round(this.f);this.a=Math.round(this.a);this.b=Math.round(this.b);this.c=Math.round(this.c);return this};function R(a,b,c,e){this.a=a;this.b=b;this.width=c;this.height=e}R.prototype.ceil=function(){this.a=Math.ceil(this.a);this.b=Math.ceil(this.b);this.width=Math.ceil(this.width);this.height=Math.ceil(this.height);return this};R.prototype.floor=function(){this.a=Math.floor(this.a);this.b=Math.floor(this.b);this.width=Math.floor(this.width);this.height=Math.floor(this.height);return this};
|
||||
R.prototype.round=function(){this.a=Math.round(this.a);this.b=Math.round(this.b);this.width=Math.round(this.width);this.height=Math.round(this.height);return this};var La="function"===typeof ShadowRoot;function S(a){for(a=a.parentNode;a&&1!=a.nodeType&&9!=a.nodeType&&11!=a.nodeType;)a=a.parentNode;return P(a)?a:null}
|
||||
function T(a,b){b=ta(b);if("float"==b||"cssFloat"==b||"styleFloat"==b)b=Ia?"styleFloat":"cssFloat";a:{var c=b;var e=N(a);if(e.defaultView&&e.defaultView.getComputedStyle&&(e=e.defaultView.getComputedStyle(a,null))){c=e[c]||e.getPropertyValue(c)||"";break a}c=""}a=c||Ma(a,b);if(null===a)a=null;else if(0<=da(ia,b)){b:{var d=a.match(la);if(d&&(b=Number(d[1]),c=Number(d[2]),e=Number(d[3]),d=Number(d[4]),0<=b&&255>=b&&0<=c&&255>=c&&0<=e&&255>=e&&0<=d&&1>=d)){b=[b,c,e,d];break b}b=null}if(!b)b:{if(e=a.match(ma))if(b=
|
||||
Number(e[1]),c=Number(e[2]),e=Number(e[3]),0<=b&&255>=b&&0<=c&&255>=c&&0<=e&&255>=e){b=[b,c,e,1];break b}b=null}if(!b)b:{b=a.toLowerCase();c=ha[b.toLowerCase()];if(!c&&(c="#"==b.charAt(0)?b:"#"+b,4==c.length&&(c=c.replace(ja,"#$1$1$2$2$3$3")),!ka.test(c))){b=null;break b}b=[parseInt(c.substr(1,2),16),parseInt(c.substr(3,2),16),parseInt(c.substr(5,2),16),1]}a=b?"rgba("+b.join(", ")+")":a}return a}
|
||||
function Ma(a,b){var c=a.currentStyle||a.style,e=c[b];void 0===e&&"function"==aa(c.getPropertyValue)&&(e=c.getPropertyValue(b));return"inherit"!=e?void 0!==e?e:null:(a=S(a))?Ma(a,b):null}
|
||||
function U(a,b,c){function e(h){var n=V(h);return 0<n.height&&0<n.width?!0:P(h,"PATH")&&(0<n.height||0<n.width)?(h=T(h,"stroke-width"),!!h&&0<parseInt(h,10)):"hidden"!=T(h,"overflow")&&ea(h.childNodes,function(D){return 3==D.nodeType||P(D)&&e(D)})}function d(h){return Na(h)==W&&fa(h.childNodes,function(n){return!P(n)||d(n)||!e(n)})}if(!P(a))throw Error("Argument to isShown must be of type Element");if(P(a,"BODY"))return!0;if(P(a,"OPTION")||P(a,"OPTGROUP"))return a=Ja(a,function(h){return P(h,"SELECT")}),
|
||||
!!a&&U(a,!0,c);var f=Oa(a);if(f)return!!f.image&&0<f.rect.width&&0<f.rect.height&&U(f.image,b,c);if(P(a,"INPUT")&&"hidden"==a.type.toLowerCase()||P(a,"NOSCRIPT"))return!1;f=T(a,"visibility");return"collapse"!=f&&"hidden"!=f&&c(a)&&(b||0!=Pa(a))&&e(a)?!d(a):!1}var W="hidden";
|
||||
function Na(a){function b(k){function l(ba){if(ba==h)return!0;var pa=T(ba,"display");return 0==pa.lastIndexOf("inline",0)||"contents"==pa||"absolute"==qa&&"static"==T(ba,"position")?!1:!0}var qa=T(k,"position");if("fixed"==qa)return ra=!0,k==h?null:h;for(k=S(k);k&&!l(k);)k=S(k);return k}function c(k){var l=k;if("visible"==D)if(k==h&&n)l=n;else if(k==n)return{x:"visible",y:"visible"};l={x:T(l,"overflow-x"),y:T(l,"overflow-y")};k==h&&(l.x="visible"==l.x?"auto":l.x,l.y="visible"==l.y?"auto":l.y);return l}
|
||||
function e(k){if(k==h){var l=(new Ka(f)).a;k=l.scrollingElement?l.scrollingElement:za||"CSS1Compat"!=l.compatMode?l.body||l.documentElement:l.documentElement;l=l.parentWindow||l.defaultView;k=C&&Ba("10")&&l.pageYOffset!=k.scrollTop?new L(k.scrollLeft,k.scrollTop):new L(l.pageXOffset||k.scrollLeft,l.pageYOffset||k.scrollTop)}else k=new L(k.scrollLeft,k.scrollTop);return k}var d=Qa(a),f=N(a),h=f.documentElement,n=f.body,D=T(h,"overflow"),ra;for(a=b(a);a;a=b(a)){var q=c(a);if("visible"!=q.x||"visible"!=
|
||||
q.y){var t=V(a);if(0==t.width||0==t.height)return W;var z=d.a<t.a,O=d.b<t.b;if(z&&"hidden"==q.x||O&&"hidden"==q.y)return W;if(z&&"visible"!=q.x||O&&"visible"!=q.y){z=e(a);O=d.b<t.b-z.y;if(d.a<t.a-z.x&&"visible"!=q.x||O&&"visible"!=q.x)return W;d=Na(a);return d==W?W:"scroll"}z=d.c>=t.a+t.width;t=d.f>=t.b+t.height;if(z&&"hidden"==q.x||t&&"hidden"==q.y)return W;if(z&&"visible"!=q.x||t&&"visible"!=q.y){if(ra&&(q=e(a),d.c>=h.scrollWidth-q.x||d.a>=h.scrollHeight-q.y))return W;d=Na(a);return d==W?W:"scroll"}}}return"none"}
|
||||
function V(a){var b=Oa(a);if(b)return b.rect;if(P(a,"HTML"))return a=N(a),a=((a?a.parentWindow||a.defaultView:window)||window).document,a="CSS1Compat"==a.compatMode?a.documentElement:a.body,a=new M(a.clientWidth,a.clientHeight),new R(0,0,a.width,a.height);try{var c=a.getBoundingClientRect()}catch(e){return new R(0,0,0,0)}b=new R(c.left,c.top,c.right-c.left,c.bottom-c.top);C&&a.ownerDocument.body&&(a=N(a),b.a-=a.documentElement.clientLeft+a.body.clientLeft,b.b-=a.documentElement.clientTop+a.body.clientTop);
|
||||
return b}
|
||||
function Oa(a){var b=P(a,"MAP");if(!b&&!P(a,"AREA"))return null;var c=b?a:P(a.parentNode,"MAP")?a.parentNode:null,e=null,d=null;if(c&&c.name){e='*[usemap="#'+c.name+'"]';c=N(c);var f;if(f="function"!=aa(c.querySelector)&&C&&(C?0<=na(I,8):Ba(8))){f=c.querySelector;var h=typeof f;f=!("object"==h&&null!=f||"function"==h)}if(f)throw Error("CSS selection is not supported");if(!e)throw new m(32,"No selector specified");e=u(e);try{var n=c.querySelector(e)}catch(D){throw new m(32,"An invalid or illegal selector was specified");}if(e=
|
||||
n&&1==n.nodeType?n:null)d=V(e),b||"default"==a.shape.toLowerCase()||(a=Ra(a),b=Math.min(Math.max(a.a,0),d.width),n=Math.min(Math.max(a.b,0),d.height),d=new R(b+d.a,n+d.b,Math.min(a.width,d.width-b),Math.min(a.height,d.height-n)))}return{image:e,rect:d||new R(0,0,0,0)}}
|
||||
function Ra(a){var b=a.shape.toLowerCase();a=a.coords.split(",");if("rect"==b&&4==a.length){b=a[0];var c=a[1];return new R(b,c,a[2]-b,a[3]-c)}if("circle"==b&&3==a.length)return b=a[2],new R(a[0]-b,a[1]-b,2*b,2*b);if("poly"==b&&2<a.length){b=a[0];c=a[1];for(var e=b,d=c,f=2;f+1<a.length;f+=2)b=Math.min(b,a[f]),e=Math.max(e,a[f]),c=Math.min(c,a[f+1]),d=Math.max(d,a[f+1]);return new R(b,c,e-b,d-c)}return new R(0,0,0,0)}function Qa(a){a=V(a);return new Q(a.b,a.a+a.width,a.b+a.height,a.a)}
|
||||
function Pa(a){if(Ia){if("relative"==T(a,"position"))return 1;a=T(a,"filter");return(a=a.match(/^alpha\(opacity=(\d*)\)/)||a.match(/^progid:DXImageTransform.Microsoft.Alpha\(Opacity=(\d*)\)/))?Number(a[1])/100:1}return Sa(a)}function Sa(a){var b=1,c=T(a,"opacity");c&&(b=Number(c));(a=S(a))&&(b*=Sa(a));return b};function Ta(a,b){function c(e){if(P(e)&&"none"==T(e,"display"))return!1;var d;if((d=e.parentNode)&&d.shadowRoot&&void 0!==e.assignedSlot)d=e.assignedSlot?e.assignedSlot.parentNode:null;else if(e.getDestinationInsertionPoints){var f=e.getDestinationInsertionPoints();0<f.length&&(d=f[f.length-1])}if(La&&d instanceof ShadowRoot){if(d.host.shadowRoot&&d.host.shadowRoot!==d)return!1;d=d.host}return!d||9!=d.nodeType&&11!=d.nodeType?d&&P(d,"DETAILS")&&!d.open&&!P(e,"SUMMARY")?!1:!!d&&c(d):!0}return U(a,
|
||||
!!b,c)}var X=["_"],Y=g;X[0]in Y||"undefined"==typeof Y.execScript||Y.execScript("var "+X[0]);for(var Z;X.length&&(Z=X.shift());)X.length||void 0===Ta?Y[Z]&&Y[Z]!==Object.prototype[Z]?Y=Y[Z]:Y=Y[Z]={}:Y[Z]=Ta;; return this._.apply(null,arguments);}).apply({navigator:typeof window!='undefined'?window.navigator:null,document:typeof window!='undefined'?window.document:null}, arguments);}
|
28
lib/python3.13/site-packages/selenium/webdriver/remote/locator_converter.py
Executable file
28
lib/python3.13/site-packages/selenium/webdriver/remote/locator_converter.py
Executable file
@ -0,0 +1,28 @@
|
||||
# Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The SFC licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
class LocatorConverter:
|
||||
def convert(self, by, value):
|
||||
# Default conversion logic
|
||||
if by == "id":
|
||||
return "css selector", f'[id="{value}"]'
|
||||
elif by == "class name":
|
||||
return "css selector", f".{value}"
|
||||
elif by == "name":
|
||||
return "css selector", f'[name="{value}"]'
|
||||
return by, value
|
81
lib/python3.13/site-packages/selenium/webdriver/remote/mobile.py
Executable file
81
lib/python3.13/site-packages/selenium/webdriver/remote/mobile.py
Executable file
@ -0,0 +1,81 @@
|
||||
# Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The SFC licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from .command import Command
|
||||
|
||||
|
||||
class _ConnectionType:
|
||||
def __init__(self, mask):
|
||||
self.mask = mask
|
||||
|
||||
@property
|
||||
def airplane_mode(self):
|
||||
return self.mask % 2 == 1
|
||||
|
||||
@property
|
||||
def wifi(self):
|
||||
return (self.mask / 2) % 2 == 1
|
||||
|
||||
@property
|
||||
def data(self):
|
||||
return (self.mask / 4) > 0
|
||||
|
||||
|
||||
class Mobile:
|
||||
ConnectionType = _ConnectionType
|
||||
ALL_NETWORK = ConnectionType(6)
|
||||
WIFI_NETWORK = ConnectionType(2)
|
||||
DATA_NETWORK = ConnectionType(4)
|
||||
AIRPLANE_MODE = ConnectionType(1)
|
||||
|
||||
def __init__(self, driver):
|
||||
import weakref
|
||||
|
||||
self._driver = weakref.proxy(driver)
|
||||
|
||||
@property
|
||||
def network_connection(self):
|
||||
return self.ConnectionType(self._driver.execute(Command.GET_NETWORK_CONNECTION)["value"])
|
||||
|
||||
def set_network_connection(self, network):
|
||||
"""Set the network connection for the remote device.
|
||||
|
||||
Example of setting airplane mode::
|
||||
|
||||
driver.mobile.set_network_connection(driver.mobile.AIRPLANE_MODE)
|
||||
"""
|
||||
mode = network.mask if isinstance(network, self.ConnectionType) else network
|
||||
return self.ConnectionType(
|
||||
self._driver.execute(
|
||||
Command.SET_NETWORK_CONNECTION, {"name": "network_connection", "parameters": {"type": mode}}
|
||||
)["value"]
|
||||
)
|
||||
|
||||
@property
|
||||
def context(self):
|
||||
"""Returns the current context (Native or WebView)."""
|
||||
return self._driver.execute(Command.CURRENT_CONTEXT_HANDLE)
|
||||
|
||||
@context.setter
|
||||
def context(self, new_context) -> None:
|
||||
"""Sets the current context."""
|
||||
self._driver.execute(Command.SWITCH_TO_CONTEXT, {"name": new_context})
|
||||
|
||||
@property
|
||||
def contexts(self):
|
||||
"""Returns a list of available contexts."""
|
||||
return self._driver.execute(Command.CONTEXT_HANDLES)
|
476
lib/python3.13/site-packages/selenium/webdriver/remote/remote_connection.py
Executable file
476
lib/python3.13/site-packages/selenium/webdriver/remote/remote_connection.py
Executable file
@ -0,0 +1,476 @@
|
||||
# Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The SFC licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
import platform
|
||||
import string
|
||||
import warnings
|
||||
from base64 import b64encode
|
||||
from typing import Optional
|
||||
from urllib import parse
|
||||
|
||||
import urllib3
|
||||
|
||||
from selenium import __version__
|
||||
|
||||
from . import utils
|
||||
from .client_config import ClientConfig
|
||||
from .command import Command
|
||||
from .errorhandler import ErrorCode
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
remote_commands = {
|
||||
Command.NEW_SESSION: ("POST", "/session"),
|
||||
Command.QUIT: ("DELETE", "/session/$sessionId"),
|
||||
Command.W3C_GET_CURRENT_WINDOW_HANDLE: ("GET", "/session/$sessionId/window"),
|
||||
Command.W3C_GET_WINDOW_HANDLES: ("GET", "/session/$sessionId/window/handles"),
|
||||
Command.GET: ("POST", "/session/$sessionId/url"),
|
||||
Command.GO_FORWARD: ("POST", "/session/$sessionId/forward"),
|
||||
Command.GO_BACK: ("POST", "/session/$sessionId/back"),
|
||||
Command.REFRESH: ("POST", "/session/$sessionId/refresh"),
|
||||
Command.W3C_EXECUTE_SCRIPT: ("POST", "/session/$sessionId/execute/sync"),
|
||||
Command.W3C_EXECUTE_SCRIPT_ASYNC: ("POST", "/session/$sessionId/execute/async"),
|
||||
Command.GET_CURRENT_URL: ("GET", "/session/$sessionId/url"),
|
||||
Command.GET_TITLE: ("GET", "/session/$sessionId/title"),
|
||||
Command.GET_PAGE_SOURCE: ("GET", "/session/$sessionId/source"),
|
||||
Command.SCREENSHOT: ("GET", "/session/$sessionId/screenshot"),
|
||||
Command.ELEMENT_SCREENSHOT: ("GET", "/session/$sessionId/element/$id/screenshot"),
|
||||
Command.FIND_ELEMENT: ("POST", "/session/$sessionId/element"),
|
||||
Command.FIND_ELEMENTS: ("POST", "/session/$sessionId/elements"),
|
||||
Command.W3C_GET_ACTIVE_ELEMENT: ("GET", "/session/$sessionId/element/active"),
|
||||
Command.FIND_CHILD_ELEMENT: ("POST", "/session/$sessionId/element/$id/element"),
|
||||
Command.FIND_CHILD_ELEMENTS: ("POST", "/session/$sessionId/element/$id/elements"),
|
||||
Command.CLICK_ELEMENT: ("POST", "/session/$sessionId/element/$id/click"),
|
||||
Command.CLEAR_ELEMENT: ("POST", "/session/$sessionId/element/$id/clear"),
|
||||
Command.GET_ELEMENT_TEXT: ("GET", "/session/$sessionId/element/$id/text"),
|
||||
Command.SEND_KEYS_TO_ELEMENT: ("POST", "/session/$sessionId/element/$id/value"),
|
||||
Command.GET_ELEMENT_TAG_NAME: ("GET", "/session/$sessionId/element/$id/name"),
|
||||
Command.IS_ELEMENT_SELECTED: ("GET", "/session/$sessionId/element/$id/selected"),
|
||||
Command.IS_ELEMENT_ENABLED: ("GET", "/session/$sessionId/element/$id/enabled"),
|
||||
Command.GET_ELEMENT_RECT: ("GET", "/session/$sessionId/element/$id/rect"),
|
||||
Command.GET_ELEMENT_ATTRIBUTE: ("GET", "/session/$sessionId/element/$id/attribute/$name"),
|
||||
Command.GET_ELEMENT_PROPERTY: ("GET", "/session/$sessionId/element/$id/property/$name"),
|
||||
Command.GET_ELEMENT_ARIA_ROLE: ("GET", "/session/$sessionId/element/$id/computedrole"),
|
||||
Command.GET_ELEMENT_ARIA_LABEL: ("GET", "/session/$sessionId/element/$id/computedlabel"),
|
||||
Command.GET_SHADOW_ROOT: ("GET", "/session/$sessionId/element/$id/shadow"),
|
||||
Command.FIND_ELEMENT_FROM_SHADOW_ROOT: ("POST", "/session/$sessionId/shadow/$shadowId/element"),
|
||||
Command.FIND_ELEMENTS_FROM_SHADOW_ROOT: ("POST", "/session/$sessionId/shadow/$shadowId/elements"),
|
||||
Command.GET_ALL_COOKIES: ("GET", "/session/$sessionId/cookie"),
|
||||
Command.ADD_COOKIE: ("POST", "/session/$sessionId/cookie"),
|
||||
Command.GET_COOKIE: ("GET", "/session/$sessionId/cookie/$name"),
|
||||
Command.DELETE_ALL_COOKIES: ("DELETE", "/session/$sessionId/cookie"),
|
||||
Command.DELETE_COOKIE: ("DELETE", "/session/$sessionId/cookie/$name"),
|
||||
Command.SWITCH_TO_FRAME: ("POST", "/session/$sessionId/frame"),
|
||||
Command.SWITCH_TO_PARENT_FRAME: ("POST", "/session/$sessionId/frame/parent"),
|
||||
Command.SWITCH_TO_WINDOW: ("POST", "/session/$sessionId/window"),
|
||||
Command.NEW_WINDOW: ("POST", "/session/$sessionId/window/new"),
|
||||
Command.CLOSE: ("DELETE", "/session/$sessionId/window"),
|
||||
Command.GET_ELEMENT_VALUE_OF_CSS_PROPERTY: ("GET", "/session/$sessionId/element/$id/css/$propertyName"),
|
||||
Command.EXECUTE_ASYNC_SCRIPT: ("POST", "/session/$sessionId/execute_async"),
|
||||
Command.SET_TIMEOUTS: ("POST", "/session/$sessionId/timeouts"),
|
||||
Command.GET_TIMEOUTS: ("GET", "/session/$sessionId/timeouts"),
|
||||
Command.W3C_DISMISS_ALERT: ("POST", "/session/$sessionId/alert/dismiss"),
|
||||
Command.W3C_ACCEPT_ALERT: ("POST", "/session/$sessionId/alert/accept"),
|
||||
Command.W3C_SET_ALERT_VALUE: ("POST", "/session/$sessionId/alert/text"),
|
||||
Command.W3C_GET_ALERT_TEXT: ("GET", "/session/$sessionId/alert/text"),
|
||||
Command.W3C_ACTIONS: ("POST", "/session/$sessionId/actions"),
|
||||
Command.W3C_CLEAR_ACTIONS: ("DELETE", "/session/$sessionId/actions"),
|
||||
Command.SET_WINDOW_RECT: ("POST", "/session/$sessionId/window/rect"),
|
||||
Command.GET_WINDOW_RECT: ("GET", "/session/$sessionId/window/rect"),
|
||||
Command.W3C_MAXIMIZE_WINDOW: ("POST", "/session/$sessionId/window/maximize"),
|
||||
Command.SET_SCREEN_ORIENTATION: ("POST", "/session/$sessionId/orientation"),
|
||||
Command.GET_SCREEN_ORIENTATION: ("GET", "/session/$sessionId/orientation"),
|
||||
Command.GET_NETWORK_CONNECTION: ("GET", "/session/$sessionId/network_connection"),
|
||||
Command.SET_NETWORK_CONNECTION: ("POST", "/session/$sessionId/network_connection"),
|
||||
Command.GET_LOG: ("POST", "/session/$sessionId/se/log"),
|
||||
Command.GET_AVAILABLE_LOG_TYPES: ("GET", "/session/$sessionId/se/log/types"),
|
||||
Command.CURRENT_CONTEXT_HANDLE: ("GET", "/session/$sessionId/context"),
|
||||
Command.CONTEXT_HANDLES: ("GET", "/session/$sessionId/contexts"),
|
||||
Command.SWITCH_TO_CONTEXT: ("POST", "/session/$sessionId/context"),
|
||||
Command.FULLSCREEN_WINDOW: ("POST", "/session/$sessionId/window/fullscreen"),
|
||||
Command.MINIMIZE_WINDOW: ("POST", "/session/$sessionId/window/minimize"),
|
||||
Command.PRINT_PAGE: ("POST", "/session/$sessionId/print"),
|
||||
Command.ADD_VIRTUAL_AUTHENTICATOR: ("POST", "/session/$sessionId/webauthn/authenticator"),
|
||||
Command.REMOVE_VIRTUAL_AUTHENTICATOR: (
|
||||
"DELETE",
|
||||
"/session/$sessionId/webauthn/authenticator/$authenticatorId",
|
||||
),
|
||||
Command.ADD_CREDENTIAL: ("POST", "/session/$sessionId/webauthn/authenticator/$authenticatorId/credential"),
|
||||
Command.GET_CREDENTIALS: ("GET", "/session/$sessionId/webauthn/authenticator/$authenticatorId/credentials"),
|
||||
Command.REMOVE_CREDENTIAL: (
|
||||
"DELETE",
|
||||
"/session/$sessionId/webauthn/authenticator/$authenticatorId/credentials/$credentialId",
|
||||
),
|
||||
Command.REMOVE_ALL_CREDENTIALS: (
|
||||
"DELETE",
|
||||
"/session/$sessionId/webauthn/authenticator/$authenticatorId/credentials",
|
||||
),
|
||||
Command.SET_USER_VERIFIED: ("POST", "/session/$sessionId/webauthn/authenticator/$authenticatorId/uv"),
|
||||
Command.UPLOAD_FILE: ("POST", "/session/$sessionId/se/file"),
|
||||
Command.GET_DOWNLOADABLE_FILES: ("GET", "/session/$sessionId/se/files"),
|
||||
Command.DOWNLOAD_FILE: ("POST", "/session/$sessionId/se/files"),
|
||||
Command.DELETE_DOWNLOADABLE_FILES: ("DELETE", "/session/$sessionId/se/files"),
|
||||
}
|
||||
|
||||
|
||||
class RemoteConnection:
|
||||
"""A connection with the Remote WebDriver server.
|
||||
|
||||
Communicates with the server using the WebDriver wire protocol:
|
||||
https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol
|
||||
"""
|
||||
|
||||
browser_name = None
|
||||
# Keep backward compatibility for AppiumConnection - https://github.com/SeleniumHQ/selenium/issues/14694
|
||||
import os
|
||||
import socket
|
||||
|
||||
import certifi
|
||||
|
||||
_timeout = (
|
||||
float(os.getenv("GLOBAL_DEFAULT_TIMEOUT", str(socket.getdefaulttimeout())))
|
||||
if os.getenv("GLOBAL_DEFAULT_TIMEOUT") is not None
|
||||
else socket.getdefaulttimeout()
|
||||
)
|
||||
_ca_certs = os.getenv("REQUESTS_CA_BUNDLE") if "REQUESTS_CA_BUNDLE" in os.environ else certifi.where()
|
||||
_client_config: ClientConfig = None
|
||||
|
||||
system = platform.system().lower()
|
||||
if system == "darwin":
|
||||
system = "mac"
|
||||
|
||||
# Class variables for headers
|
||||
extra_headers = None
|
||||
user_agent = f"selenium/{__version__} (python {system})"
|
||||
|
||||
@classmethod
|
||||
def get_timeout(cls):
|
||||
""":Returns:
|
||||
|
||||
Timeout value in seconds for all http requests made to the
|
||||
Remote Connection
|
||||
"""
|
||||
warnings.warn(
|
||||
"get_timeout() in RemoteConnection is deprecated, get timeout from ClientConfig instance instead",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return cls._client_config.timeout
|
||||
|
||||
@classmethod
|
||||
def set_timeout(cls, timeout):
|
||||
"""Override the default timeout.
|
||||
|
||||
:Args:
|
||||
- timeout - timeout value for http requests in seconds
|
||||
"""
|
||||
warnings.warn(
|
||||
"set_timeout() in RemoteConnection is deprecated, set timeout to ClientConfig instance in constructor instead",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
cls._client_config.timeout = timeout
|
||||
|
||||
@classmethod
|
||||
def reset_timeout(cls):
|
||||
"""Reset the http request timeout to socket._GLOBAL_DEFAULT_TIMEOUT."""
|
||||
warnings.warn(
|
||||
"reset_timeout() in RemoteConnection is deprecated, use reset_timeout() in ClientConfig instance instead",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
cls._client_config.reset_timeout()
|
||||
|
||||
@classmethod
|
||||
def get_certificate_bundle_path(cls):
|
||||
""":Returns:
|
||||
|
||||
Paths of the .pem encoded certificate to verify connection to
|
||||
command executor. Defaults to certifi.where() or
|
||||
REQUESTS_CA_BUNDLE env variable if set.
|
||||
"""
|
||||
warnings.warn(
|
||||
"get_certificate_bundle_path() in RemoteConnection is deprecated, get ca_certs from ClientConfig instance instead",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return cls._client_config.ca_certs
|
||||
|
||||
@classmethod
|
||||
def set_certificate_bundle_path(cls, path):
|
||||
"""Set the path to the certificate bundle to verify connection to
|
||||
command executor. Can also be set to None to disable certificate
|
||||
validation.
|
||||
|
||||
:Args:
|
||||
- path - path of a .pem encoded certificate chain.
|
||||
"""
|
||||
warnings.warn(
|
||||
"set_certificate_bundle_path() in RemoteConnection is deprecated, set ca_certs to ClientConfig instance in constructor instead",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
cls._client_config.ca_certs = path
|
||||
|
||||
@classmethod
|
||||
def get_remote_connection_headers(cls, parsed_url, keep_alive=False):
|
||||
"""Get headers for remote request.
|
||||
|
||||
:Args:
|
||||
- parsed_url - The parsed url
|
||||
- keep_alive (Boolean) - Is this a keep-alive connection (default: False)
|
||||
"""
|
||||
|
||||
headers = {
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json;charset=UTF-8",
|
||||
"User-Agent": cls.user_agent,
|
||||
}
|
||||
|
||||
if parsed_url.username:
|
||||
base64string = b64encode(f"{parsed_url.username}:{parsed_url.password}".encode())
|
||||
headers.update({"Authorization": f"Basic {base64string.decode()}"})
|
||||
|
||||
if keep_alive:
|
||||
headers.update({"Connection": "keep-alive"})
|
||||
|
||||
if cls.extra_headers:
|
||||
headers.update(cls.extra_headers)
|
||||
|
||||
return headers
|
||||
|
||||
def _identify_http_proxy_auth(self):
|
||||
url = self._proxy_url
|
||||
url = url[url.find(":") + 3 :]
|
||||
return "@" in url and len(url[: url.find("@")]) > 0
|
||||
|
||||
def _separate_http_proxy_auth(self):
|
||||
url = self._proxy_url
|
||||
protocol = url[: url.find(":") + 3]
|
||||
no_protocol = url[len(protocol) :]
|
||||
auth = no_protocol[: no_protocol.find("@")]
|
||||
proxy_without_auth = protocol + no_protocol[len(auth) + 1 :]
|
||||
return proxy_without_auth, auth
|
||||
|
||||
def _get_connection_manager(self):
|
||||
pool_manager_init_args = {"timeout": self._client_config.timeout}
|
||||
pool_manager_init_args.update(
|
||||
self._client_config.init_args_for_pool_manager.get("init_args_for_pool_manager", {})
|
||||
)
|
||||
|
||||
if self._client_config.ignore_certificates:
|
||||
pool_manager_init_args["cert_reqs"] = "CERT_NONE"
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
elif self._client_config.ca_certs:
|
||||
pool_manager_init_args["cert_reqs"] = "CERT_REQUIRED"
|
||||
pool_manager_init_args["ca_certs"] = self._client_config.ca_certs
|
||||
|
||||
if self._proxy_url:
|
||||
if self._proxy_url.lower().startswith("sock"):
|
||||
from urllib3.contrib.socks import SOCKSProxyManager
|
||||
|
||||
return SOCKSProxyManager(self._proxy_url, **pool_manager_init_args)
|
||||
if self._identify_http_proxy_auth():
|
||||
self._proxy_url, self._basic_proxy_auth = self._separate_http_proxy_auth()
|
||||
pool_manager_init_args["proxy_headers"] = urllib3.make_headers(proxy_basic_auth=self._basic_proxy_auth)
|
||||
return urllib3.ProxyManager(self._proxy_url, **pool_manager_init_args)
|
||||
|
||||
return urllib3.PoolManager(**pool_manager_init_args)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
remote_server_addr: Optional[str] = None,
|
||||
keep_alive: Optional[bool] = True,
|
||||
ignore_proxy: Optional[bool] = False,
|
||||
ignore_certificates: Optional[bool] = False,
|
||||
init_args_for_pool_manager: Optional[dict] = None,
|
||||
client_config: Optional[ClientConfig] = None,
|
||||
):
|
||||
self._client_config = client_config or ClientConfig(
|
||||
remote_server_addr=remote_server_addr,
|
||||
keep_alive=keep_alive,
|
||||
ignore_certificates=ignore_certificates,
|
||||
init_args_for_pool_manager=init_args_for_pool_manager,
|
||||
)
|
||||
|
||||
# Keep backward compatibility for AppiumConnection - https://github.com/SeleniumHQ/selenium/issues/14694
|
||||
RemoteConnection._timeout = self._client_config.timeout
|
||||
RemoteConnection._ca_certs = self._client_config.ca_certs
|
||||
RemoteConnection._client_config = self._client_config
|
||||
|
||||
if remote_server_addr:
|
||||
warnings.warn(
|
||||
"setting remote_server_addr in RemoteConnection() is deprecated, set in ClientConfig instance instead",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
|
||||
if not keep_alive:
|
||||
warnings.warn(
|
||||
"setting keep_alive in RemoteConnection() is deprecated, set in ClientConfig instance instead",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
|
||||
if ignore_certificates:
|
||||
warnings.warn(
|
||||
"setting ignore_certificates in RemoteConnection() is deprecated, set in ClientConfig instance instead",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
|
||||
if init_args_for_pool_manager:
|
||||
warnings.warn(
|
||||
"setting init_args_for_pool_manager in RemoteConnection() is deprecated, set in ClientConfig instance instead",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
|
||||
if ignore_proxy:
|
||||
warnings.warn(
|
||||
"setting ignore_proxy in RemoteConnection() is deprecated, set in ClientConfig instance instead",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
self._proxy_url = None
|
||||
else:
|
||||
self._proxy_url = self._client_config.get_proxy_url()
|
||||
|
||||
if self._client_config.keep_alive:
|
||||
self._conn = self._get_connection_manager()
|
||||
self._commands = remote_commands
|
||||
|
||||
extra_commands = {}
|
||||
|
||||
def add_command(self, name, method, url):
|
||||
"""Register a new command."""
|
||||
self._commands[name] = (method, url)
|
||||
|
||||
def get_command(self, name: str):
|
||||
"""Retrieve a command if it exists."""
|
||||
return self._commands.get(name)
|
||||
|
||||
def execute(self, command, params):
|
||||
"""Send a command to the remote server.
|
||||
|
||||
Any path substitutions required for the URL mapped to the command should be
|
||||
included in the command parameters.
|
||||
|
||||
:Args:
|
||||
- command - A string specifying the command to execute.
|
||||
- params - A dictionary of named parameters to send with the command as
|
||||
its JSON payload.
|
||||
"""
|
||||
command_info = self._commands.get(command) or self.extra_commands.get(command)
|
||||
assert command_info is not None, f"Unrecognised command {command}"
|
||||
path_string = command_info[1]
|
||||
path = string.Template(path_string).substitute(params)
|
||||
substitute_params = {word[1:] for word in path_string.split("/") if word.startswith("$")} # remove dollar sign
|
||||
if isinstance(params, dict) and substitute_params:
|
||||
for word in substitute_params:
|
||||
del params[word]
|
||||
data = utils.dump_json(params)
|
||||
url = f"{self._client_config.remote_server_addr}{path}"
|
||||
trimmed = self._trim_large_entries(params)
|
||||
LOGGER.debug("%s %s %s", command_info[0], url, str(trimmed))
|
||||
return self._request(command_info[0], url, body=data)
|
||||
|
||||
def _request(self, method, url, body=None):
|
||||
"""Send an HTTP request to the remote server.
|
||||
|
||||
:Args:
|
||||
- method - A string for the HTTP method to send the request with.
|
||||
- url - A string for the URL to send the request to.
|
||||
- body - A string for request body. Ignored unless method is POST or PUT.
|
||||
|
||||
:Returns:
|
||||
A dictionary with the server's parsed JSON response.
|
||||
"""
|
||||
parsed_url = parse.urlparse(url)
|
||||
headers = self.get_remote_connection_headers(parsed_url, self._client_config.keep_alive)
|
||||
auth_header = self._client_config.get_auth_header()
|
||||
|
||||
if auth_header:
|
||||
headers.update(auth_header)
|
||||
|
||||
if body and method not in ("POST", "PUT"):
|
||||
body = None
|
||||
|
||||
if self._client_config.keep_alive:
|
||||
response = self._conn.request(method, url, body=body, headers=headers, timeout=self._client_config.timeout)
|
||||
statuscode = response.status
|
||||
else:
|
||||
conn = self._get_connection_manager()
|
||||
with conn as http:
|
||||
response = http.request(method, url, body=body, headers=headers, timeout=self._client_config.timeout)
|
||||
statuscode = response.status
|
||||
data = response.data.decode("UTF-8")
|
||||
LOGGER.debug("Remote response: status=%s | data=%s | headers=%s", response.status, data, response.headers)
|
||||
try:
|
||||
if 300 <= statuscode < 304:
|
||||
return self._request("GET", response.headers.get("location", None))
|
||||
if 399 < statuscode <= 500:
|
||||
if statuscode == 401:
|
||||
return {"status": statuscode, "value": "Authorization Required"}
|
||||
return {"status": statuscode, "value": str(statuscode) if not data else data.strip()}
|
||||
content_type = []
|
||||
if response.headers.get("Content-Type", None):
|
||||
content_type = response.headers.get("Content-Type", None).split(";")
|
||||
if not any([x.startswith("image/png") for x in content_type]):
|
||||
try:
|
||||
data = utils.load_json(data.strip())
|
||||
except ValueError:
|
||||
if 199 < statuscode < 300:
|
||||
status = ErrorCode.SUCCESS
|
||||
else:
|
||||
status = ErrorCode.UNKNOWN_ERROR
|
||||
return {"status": status, "value": data.strip()}
|
||||
|
||||
# Some drivers incorrectly return a response
|
||||
# with no 'value' field when they should return null.
|
||||
if "value" not in data:
|
||||
data["value"] = None
|
||||
return data
|
||||
data = {"status": 0, "value": data}
|
||||
return data
|
||||
finally:
|
||||
LOGGER.debug("Finished Request")
|
||||
response.close()
|
||||
|
||||
def close(self):
|
||||
"""Clean up resources when finished with the remote_connection."""
|
||||
if hasattr(self, "_conn"):
|
||||
self._conn.clear()
|
||||
|
||||
def _trim_large_entries(self, input_dict, max_length=100):
|
||||
"""Truncate string values in a dictionary if they exceed max_length.
|
||||
|
||||
:param dict: Dictionary with potentially large values
|
||||
:param max_length: Maximum allowed length of string values
|
||||
:return: Dictionary with truncated string values
|
||||
"""
|
||||
output_dictionary = {}
|
||||
for key, value in input_dict.items():
|
||||
if isinstance(value, dict):
|
||||
output_dictionary[key] = self._trim_large_entries(value, max_length)
|
||||
elif isinstance(value, str) and len(value) > max_length:
|
||||
output_dictionary[key] = value[:max_length] + "..."
|
||||
else:
|
||||
output_dictionary[key] = value
|
||||
|
||||
return output_dictionary
|
33
lib/python3.13/site-packages/selenium/webdriver/remote/script_key.py
Executable file
33
lib/python3.13/site-packages/selenium/webdriver/remote/script_key.py
Executable file
@ -0,0 +1,33 @@
|
||||
# Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The SFC licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
|
||||
class ScriptKey:
|
||||
def __init__(self, id=None):
|
||||
self._id = id or uuid.uuid4()
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
return self._id
|
||||
|
||||
def __eq__(self, other):
|
||||
return self._id == other
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"ScriptKey(id={self.id})"
|
82
lib/python3.13/site-packages/selenium/webdriver/remote/shadowroot.py
Executable file
82
lib/python3.13/site-packages/selenium/webdriver/remote/shadowroot.py
Executable file
@ -0,0 +1,82 @@
|
||||
# Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The SFC licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from hashlib import md5 as md5_hash
|
||||
|
||||
from ..common.by import By
|
||||
from .command import Command
|
||||
|
||||
|
||||
class ShadowRoot:
|
||||
# TODO: We should look and see how we can create a search context like Java/.NET
|
||||
|
||||
def __init__(self, session, id_) -> None:
|
||||
self.session = session
|
||||
self._id = id_
|
||||
|
||||
def __eq__(self, other_shadowroot) -> bool:
|
||||
return self._id == other_shadowroot._id
|
||||
|
||||
def __hash__(self) -> int:
|
||||
return int(md5_hash(self._id.encode("utf-8")).hexdigest(), 16)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return '<{0.__module__}.{0.__name__} (session="{1}", element="{2}")>'.format(
|
||||
type(self), self.session.session_id, self._id
|
||||
)
|
||||
|
||||
def find_element(self, by: str = By.ID, value: str = None):
|
||||
if by == By.ID:
|
||||
by = By.CSS_SELECTOR
|
||||
value = f'[id="{value}"]'
|
||||
elif by == By.CLASS_NAME:
|
||||
by = By.CSS_SELECTOR
|
||||
value = f".{value}"
|
||||
elif by == By.NAME:
|
||||
by = By.CSS_SELECTOR
|
||||
value = f'[name="{value}"]'
|
||||
|
||||
return self._execute(Command.FIND_ELEMENT_FROM_SHADOW_ROOT, {"using": by, "value": value})["value"]
|
||||
|
||||
def find_elements(self, by: str = By.ID, value: str = None):
|
||||
if by == By.ID:
|
||||
by = By.CSS_SELECTOR
|
||||
value = f'[id="{value}"]'
|
||||
elif by == By.CLASS_NAME:
|
||||
by = By.CSS_SELECTOR
|
||||
value = f".{value}"
|
||||
elif by == By.NAME:
|
||||
by = By.CSS_SELECTOR
|
||||
value = f'[name="{value}"]'
|
||||
|
||||
return self._execute(Command.FIND_ELEMENTS_FROM_SHADOW_ROOT, {"using": by, "value": value})["value"]
|
||||
|
||||
# Private Methods
|
||||
def _execute(self, command, params=None):
|
||||
"""Executes a command against the underlying HTML element.
|
||||
|
||||
Args:
|
||||
command: The name of the command to _execute as a string.
|
||||
params: A dictionary of named parameters to send with the command.
|
||||
|
||||
Returns:
|
||||
The command's JSON response loaded into a dictionary object.
|
||||
"""
|
||||
if not params:
|
||||
params = {}
|
||||
params["shadowId"] = self._id
|
||||
return self.session.execute(command, params)
|
152
lib/python3.13/site-packages/selenium/webdriver/remote/switch_to.py
Executable file
152
lib/python3.13/site-packages/selenium/webdriver/remote/switch_to.py
Executable file
@ -0,0 +1,152 @@
|
||||
# Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The SFC licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from typing import Optional
|
||||
from typing import Union
|
||||
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from selenium.common.exceptions import NoSuchFrameException
|
||||
from selenium.common.exceptions import NoSuchWindowException
|
||||
from selenium.webdriver.common.alert import Alert
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.remote.webelement import WebElement
|
||||
|
||||
from .command import Command
|
||||
|
||||
|
||||
class SwitchTo:
|
||||
def __init__(self, driver) -> None:
|
||||
import weakref
|
||||
|
||||
self._driver = weakref.proxy(driver)
|
||||
|
||||
@property
|
||||
def active_element(self) -> WebElement:
|
||||
"""Returns the element with focus, or BODY if nothing has focus.
|
||||
|
||||
:Usage:
|
||||
::
|
||||
|
||||
element = driver.switch_to.active_element
|
||||
"""
|
||||
return self._driver.execute(Command.W3C_GET_ACTIVE_ELEMENT)["value"]
|
||||
|
||||
@property
|
||||
def alert(self) -> Alert:
|
||||
"""Switches focus to an alert on the page.
|
||||
|
||||
:Usage:
|
||||
::
|
||||
|
||||
alert = driver.switch_to.alert
|
||||
"""
|
||||
alert = Alert(self._driver)
|
||||
_ = alert.text
|
||||
return alert
|
||||
|
||||
def default_content(self) -> None:
|
||||
"""Switch focus to the default frame.
|
||||
|
||||
:Usage:
|
||||
::
|
||||
|
||||
driver.switch_to.default_content()
|
||||
"""
|
||||
self._driver.execute(Command.SWITCH_TO_FRAME, {"id": None})
|
||||
|
||||
def frame(self, frame_reference: Union[str, int, WebElement]) -> None:
|
||||
"""Switches focus to the specified frame, by index, name, or
|
||||
webelement.
|
||||
|
||||
:Args:
|
||||
- frame_reference: The name of the window to switch to, an integer representing the index,
|
||||
or a webelement that is an (i)frame to switch to.
|
||||
|
||||
:Usage:
|
||||
::
|
||||
|
||||
driver.switch_to.frame('frame_name')
|
||||
driver.switch_to.frame(1)
|
||||
driver.switch_to.frame(driver.find_elements(By.TAG_NAME, "iframe")[0])
|
||||
"""
|
||||
if isinstance(frame_reference, str):
|
||||
try:
|
||||
frame_reference = self._driver.find_element(By.ID, frame_reference)
|
||||
except NoSuchElementException:
|
||||
try:
|
||||
frame_reference = self._driver.find_element(By.NAME, frame_reference)
|
||||
except NoSuchElementException as exc:
|
||||
raise NoSuchFrameException(frame_reference) from exc
|
||||
|
||||
self._driver.execute(Command.SWITCH_TO_FRAME, {"id": frame_reference})
|
||||
|
||||
def new_window(self, type_hint: Optional[str] = None) -> None:
|
||||
"""Switches to a new top-level browsing context.
|
||||
|
||||
The type hint can be one of "tab" or "window". If not specified the
|
||||
browser will automatically select it.
|
||||
|
||||
:Usage:
|
||||
::
|
||||
|
||||
driver.switch_to.new_window('tab')
|
||||
"""
|
||||
value = self._driver.execute(Command.NEW_WINDOW, {"type": type_hint})["value"]
|
||||
self._w3c_window(value["handle"])
|
||||
|
||||
def parent_frame(self) -> None:
|
||||
"""Switches focus to the parent context. If the current context is the
|
||||
top level browsing context, the context remains unchanged.
|
||||
|
||||
:Usage:
|
||||
::
|
||||
|
||||
driver.switch_to.parent_frame()
|
||||
"""
|
||||
self._driver.execute(Command.SWITCH_TO_PARENT_FRAME)
|
||||
|
||||
def window(self, window_name: str) -> None:
|
||||
"""Switches focus to the specified window.
|
||||
|
||||
:Args:
|
||||
- window_name: The name or window handle of the window to switch to.
|
||||
|
||||
:Usage:
|
||||
::
|
||||
|
||||
driver.switch_to.window('main')
|
||||
"""
|
||||
self._w3c_window(window_name)
|
||||
|
||||
def _w3c_window(self, window_name: str) -> None:
|
||||
def send_handle(h):
|
||||
self._driver.execute(Command.SWITCH_TO_WINDOW, {"handle": h})
|
||||
|
||||
try:
|
||||
# Try using it as a handle first.
|
||||
send_handle(window_name)
|
||||
except NoSuchWindowException:
|
||||
# Check every window to try to find the given window name.
|
||||
original_handle = self._driver.current_window_handle
|
||||
handles = self._driver.window_handles
|
||||
for handle in handles:
|
||||
send_handle(handle)
|
||||
current_name = self._driver.execute_script("return window.name")
|
||||
if window_name == current_name:
|
||||
return
|
||||
send_handle(original_handle)
|
||||
raise
|
28
lib/python3.13/site-packages/selenium/webdriver/remote/utils.py
Executable file
28
lib/python3.13/site-packages/selenium/webdriver/remote/utils.py
Executable file
@ -0,0 +1,28 @@
|
||||
# Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The SFC licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
from typing import Any
|
||||
from typing import Union
|
||||
|
||||
|
||||
def dump_json(json_struct: Any) -> str:
|
||||
return json.dumps(json_struct)
|
||||
|
||||
|
||||
def load_json(s: Union[str, bytes]) -> Any:
|
||||
return json.loads(s)
|
1224
lib/python3.13/site-packages/selenium/webdriver/remote/webdriver.py
Executable file
1224
lib/python3.13/site-packages/selenium/webdriver/remote/webdriver.py
Executable file
File diff suppressed because it is too large
Load Diff
443
lib/python3.13/site-packages/selenium/webdriver/remote/webelement.py
Executable file
443
lib/python3.13/site-packages/selenium/webdriver/remote/webelement.py
Executable file
@ -0,0 +1,443 @@
|
||||
# Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The SFC licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import pkgutil
|
||||
import warnings
|
||||
import zipfile
|
||||
from abc import ABCMeta
|
||||
from base64 import b64decode
|
||||
from base64 import encodebytes
|
||||
from hashlib import md5 as md5_hash
|
||||
from io import BytesIO
|
||||
from typing import List
|
||||
|
||||
from selenium.common.exceptions import JavascriptException
|
||||
from selenium.common.exceptions import WebDriverException
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.common.utils import keys_to_typing
|
||||
|
||||
from .command import Command
|
||||
from .shadowroot import ShadowRoot
|
||||
|
||||
# TODO: When moving to supporting python 3.9 as the minimum version we can
|
||||
# use built in importlib_resources.files.
|
||||
getAttribute_js = None
|
||||
isDisplayed_js = None
|
||||
|
||||
|
||||
def _load_js():
|
||||
global getAttribute_js
|
||||
global isDisplayed_js
|
||||
_pkg = ".".join(__name__.split(".")[:-1])
|
||||
getAttribute_js = pkgutil.get_data(_pkg, "getAttribute.js").decode("utf8")
|
||||
isDisplayed_js = pkgutil.get_data(_pkg, "isDisplayed.js").decode("utf8")
|
||||
|
||||
|
||||
class BaseWebElement(metaclass=ABCMeta):
|
||||
"""Abstract Base Class for WebElement.
|
||||
|
||||
ABC's will allow custom types to be registered as a WebElement to
|
||||
pass type checks.
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class WebElement(BaseWebElement):
|
||||
"""Represents a DOM element.
|
||||
|
||||
Generally, all interesting operations that interact with a document will be
|
||||
performed through this interface.
|
||||
|
||||
All method calls will do a freshness check to ensure that the element
|
||||
reference is still valid. This essentially determines whether the
|
||||
element is still attached to the DOM. If this test fails, then an
|
||||
``StaleElementReferenceException`` is thrown, and all future calls to this
|
||||
instance will fail.
|
||||
"""
|
||||
|
||||
def __init__(self, parent, id_) -> None:
|
||||
self._parent = parent
|
||||
self._id = id_
|
||||
|
||||
def __repr__(self):
|
||||
return f'<{type(self).__module__}.{type(self).__name__} (session="{self._parent.session_id}", element="{self._id}")>'
|
||||
|
||||
@property
|
||||
def tag_name(self) -> str:
|
||||
"""This element's ``tagName`` property."""
|
||||
return self._execute(Command.GET_ELEMENT_TAG_NAME)["value"]
|
||||
|
||||
@property
|
||||
def text(self) -> str:
|
||||
"""The text of the element."""
|
||||
return self._execute(Command.GET_ELEMENT_TEXT)["value"]
|
||||
|
||||
def click(self) -> None:
|
||||
"""Clicks the element."""
|
||||
self._execute(Command.CLICK_ELEMENT)
|
||||
|
||||
def submit(self) -> None:
|
||||
"""Submits a form."""
|
||||
script = (
|
||||
"/* submitForm */var form = arguments[0];\n"
|
||||
'while (form.nodeName != "FORM" && form.parentNode) {\n'
|
||||
" form = form.parentNode;\n"
|
||||
"}\n"
|
||||
"if (!form) { throw Error('Unable to find containing form element'); }\n"
|
||||
"if (!form.ownerDocument) { throw Error('Unable to find owning document'); }\n"
|
||||
"var e = form.ownerDocument.createEvent('Event');\n"
|
||||
"e.initEvent('submit', true, true);\n"
|
||||
"if (form.dispatchEvent(e)) { HTMLFormElement.prototype.submit.call(form) }\n"
|
||||
)
|
||||
|
||||
try:
|
||||
self._parent.execute_script(script, self)
|
||||
except JavascriptException as exc:
|
||||
raise WebDriverException("To submit an element, it must be nested inside a form element") from exc
|
||||
|
||||
def clear(self) -> None:
|
||||
"""Clears the text if it's a text entry element."""
|
||||
self._execute(Command.CLEAR_ELEMENT)
|
||||
|
||||
def get_property(self, name) -> str | bool | WebElement | dict:
|
||||
"""Gets the given property of the element.
|
||||
|
||||
:Args:
|
||||
- name - Name of the property to retrieve.
|
||||
|
||||
:Usage:
|
||||
::
|
||||
|
||||
text_length = target_element.get_property("text_length")
|
||||
"""
|
||||
try:
|
||||
return self._execute(Command.GET_ELEMENT_PROPERTY, {"name": name})["value"]
|
||||
except WebDriverException:
|
||||
# if we hit an end point that doesn't understand getElementProperty lets fake it
|
||||
return self.parent.execute_script("return arguments[0][arguments[1]]", self, name)
|
||||
|
||||
def get_dom_attribute(self, name) -> str:
|
||||
"""Gets the given attribute of the element. Unlike
|
||||
:func:`~selenium.webdriver.remote.BaseWebElement.get_attribute`, this
|
||||
method only returns attributes declared in the element's HTML markup.
|
||||
|
||||
:Args:
|
||||
- name - Name of the attribute to retrieve.
|
||||
|
||||
:Usage:
|
||||
::
|
||||
|
||||
text_length = target_element.get_dom_attribute("class")
|
||||
"""
|
||||
return self._execute(Command.GET_ELEMENT_ATTRIBUTE, {"name": name})["value"]
|
||||
|
||||
def get_attribute(self, name) -> str | None:
|
||||
"""Gets the given attribute or property of the element.
|
||||
|
||||
This method will first try to return the value of a property with the
|
||||
given name. If a property with that name doesn't exist, it returns the
|
||||
value of the attribute with the same name. If there's no attribute with
|
||||
that name, ``None`` is returned.
|
||||
|
||||
Values which are considered truthy, that is equals "true" or "false",
|
||||
are returned as booleans. All other non-``None`` values are returned
|
||||
as strings. For attributes or properties which do not exist, ``None``
|
||||
is returned.
|
||||
|
||||
To obtain the exact value of the attribute or property,
|
||||
use :func:`~selenium.webdriver.remote.BaseWebElement.get_dom_attribute` or
|
||||
:func:`~selenium.webdriver.remote.BaseWebElement.get_property` methods respectively.
|
||||
|
||||
:Args:
|
||||
- name - Name of the attribute/property to retrieve.
|
||||
|
||||
Example::
|
||||
|
||||
# Check if the "active" CSS class is applied to an element.
|
||||
is_active = "active" in target_element.get_attribute("class")
|
||||
"""
|
||||
if getAttribute_js is None:
|
||||
_load_js()
|
||||
attribute_value = self.parent.execute_script(
|
||||
f"/* getAttribute */return ({getAttribute_js}).apply(null, arguments);", self, name
|
||||
)
|
||||
return attribute_value
|
||||
|
||||
def is_selected(self) -> bool:
|
||||
"""Returns whether the element is selected.
|
||||
|
||||
Can be used to check if a checkbox or radio button is selected.
|
||||
"""
|
||||
return self._execute(Command.IS_ELEMENT_SELECTED)["value"]
|
||||
|
||||
def is_enabled(self) -> bool:
|
||||
"""Returns whether the element is enabled."""
|
||||
return self._execute(Command.IS_ELEMENT_ENABLED)["value"]
|
||||
|
||||
def send_keys(self, *value: str) -> None:
|
||||
"""Simulates typing into the element.
|
||||
|
||||
:Args:
|
||||
- value - A string for typing, or setting form fields. For setting
|
||||
file inputs, this could be a local file path.
|
||||
|
||||
Use this to send simple key events or to fill out form fields::
|
||||
|
||||
form_textfield = driver.find_element(By.NAME, 'username')
|
||||
form_textfield.send_keys("admin")
|
||||
|
||||
This can also be used to set file inputs.
|
||||
|
||||
::
|
||||
|
||||
file_input = driver.find_element(By.NAME, 'profilePic')
|
||||
file_input.send_keys("path/to/profilepic.gif")
|
||||
# Generally it's better to wrap the file path in one of the methods
|
||||
# in os.path to return the actual path to support cross OS testing.
|
||||
# file_input.send_keys(os.path.abspath("path/to/profilepic.gif"))
|
||||
"""
|
||||
# transfer file to another machine only if remote driver is used
|
||||
# the same behaviour as for java binding
|
||||
if self.parent._is_remote:
|
||||
local_files = list(
|
||||
map(
|
||||
lambda keys_to_send: self.parent.file_detector.is_local_file(str(keys_to_send)),
|
||||
"".join(map(str, value)).split("\n"),
|
||||
)
|
||||
)
|
||||
if None not in local_files:
|
||||
remote_files = []
|
||||
for file in local_files:
|
||||
remote_files.append(self._upload(file))
|
||||
value = tuple("\n".join(remote_files))
|
||||
|
||||
self._execute(
|
||||
Command.SEND_KEYS_TO_ELEMENT, {"text": "".join(keys_to_typing(value)), "value": keys_to_typing(value)}
|
||||
)
|
||||
|
||||
@property
|
||||
def shadow_root(self) -> ShadowRoot:
|
||||
"""Returns a shadow root of the element if there is one or an error.
|
||||
Only works from Chromium 96, Firefox 96, and Safari 16.4 onwards.
|
||||
|
||||
:Returns:
|
||||
- ShadowRoot object or
|
||||
- NoSuchShadowRoot - if no shadow root was attached to element
|
||||
"""
|
||||
return self._execute(Command.GET_SHADOW_ROOT)["value"]
|
||||
|
||||
# RenderedWebElement Items
|
||||
def is_displayed(self) -> bool:
|
||||
"""Whether the element is visible to a user."""
|
||||
# Only go into this conditional for browsers that don't use the atom themselves
|
||||
if isDisplayed_js is None:
|
||||
_load_js()
|
||||
return self.parent.execute_script(f"/* isDisplayed */return ({isDisplayed_js}).apply(null, arguments);", self)
|
||||
|
||||
@property
|
||||
def location_once_scrolled_into_view(self) -> dict:
|
||||
"""THIS PROPERTY MAY CHANGE WITHOUT WARNING. Use this to discover where
|
||||
on the screen an element is so that we can click it. This method should
|
||||
cause the element to be scrolled into view.
|
||||
|
||||
Returns the top lefthand corner location on the screen, or zero
|
||||
coordinates if the element is not visible.
|
||||
"""
|
||||
old_loc = self._execute(
|
||||
Command.W3C_EXECUTE_SCRIPT,
|
||||
{
|
||||
"script": "arguments[0].scrollIntoView(true); return arguments[0].getBoundingClientRect()",
|
||||
"args": [self],
|
||||
},
|
||||
)["value"]
|
||||
return {"x": round(old_loc["x"]), "y": round(old_loc["y"])}
|
||||
|
||||
@property
|
||||
def size(self) -> dict:
|
||||
"""The size of the element."""
|
||||
size = self._execute(Command.GET_ELEMENT_RECT)["value"]
|
||||
new_size = {"height": size["height"], "width": size["width"]}
|
||||
return new_size
|
||||
|
||||
def value_of_css_property(self, property_name) -> str:
|
||||
"""The value of a CSS property."""
|
||||
return self._execute(Command.GET_ELEMENT_VALUE_OF_CSS_PROPERTY, {"propertyName": property_name})["value"]
|
||||
|
||||
@property
|
||||
def location(self) -> dict:
|
||||
"""The location of the element in the renderable canvas."""
|
||||
old_loc = self._execute(Command.GET_ELEMENT_RECT)["value"]
|
||||
new_loc = {"x": round(old_loc["x"]), "y": round(old_loc["y"])}
|
||||
return new_loc
|
||||
|
||||
@property
|
||||
def rect(self) -> dict:
|
||||
"""A dictionary with the size and location of the element."""
|
||||
return self._execute(Command.GET_ELEMENT_RECT)["value"]
|
||||
|
||||
@property
|
||||
def aria_role(self) -> str:
|
||||
"""Returns the ARIA role of the current web element."""
|
||||
return self._execute(Command.GET_ELEMENT_ARIA_ROLE)["value"]
|
||||
|
||||
@property
|
||||
def accessible_name(self) -> str:
|
||||
"""Returns the ARIA Level of the current webelement."""
|
||||
return self._execute(Command.GET_ELEMENT_ARIA_LABEL)["value"]
|
||||
|
||||
@property
|
||||
def screenshot_as_base64(self) -> str:
|
||||
"""Gets the screenshot of the current element as a base64 encoded
|
||||
string.
|
||||
|
||||
:Usage:
|
||||
::
|
||||
|
||||
img_b64 = element.screenshot_as_base64
|
||||
"""
|
||||
return self._execute(Command.ELEMENT_SCREENSHOT)["value"]
|
||||
|
||||
@property
|
||||
def screenshot_as_png(self) -> bytes:
|
||||
"""Gets the screenshot of the current element as a binary data.
|
||||
|
||||
:Usage:
|
||||
::
|
||||
|
||||
element_png = element.screenshot_as_png
|
||||
"""
|
||||
return b64decode(self.screenshot_as_base64.encode("ascii"))
|
||||
|
||||
def screenshot(self, filename) -> bool:
|
||||
"""Saves a screenshot of the current element to a PNG image file.
|
||||
Returns False if there is any IOError, else returns True. Use full
|
||||
paths in your filename.
|
||||
|
||||
:Args:
|
||||
- filename: The full path you wish to save your screenshot to. This
|
||||
should end with a `.png` extension.
|
||||
|
||||
:Usage:
|
||||
::
|
||||
|
||||
element.screenshot('/Screenshots/foo.png')
|
||||
"""
|
||||
if not filename.lower().endswith(".png"):
|
||||
warnings.warn(
|
||||
"name used for saved screenshot does not match file type. It should end with a `.png` extension",
|
||||
UserWarning,
|
||||
)
|
||||
png = self.screenshot_as_png
|
||||
try:
|
||||
with open(filename, "wb") as f:
|
||||
f.write(png)
|
||||
except OSError:
|
||||
return False
|
||||
finally:
|
||||
del png
|
||||
return True
|
||||
|
||||
@property
|
||||
def parent(self):
|
||||
"""Internal reference to the WebDriver instance this element was found
|
||||
from."""
|
||||
return self._parent
|
||||
|
||||
@property
|
||||
def id(self) -> str:
|
||||
"""Internal ID used by selenium.
|
||||
|
||||
This is mainly for internal use. Simple use cases such as checking if 2
|
||||
webelements refer to the same element, can be done using ``==``::
|
||||
|
||||
if element1 == element2:
|
||||
print("These 2 are equal")
|
||||
"""
|
||||
return self._id
|
||||
|
||||
def __eq__(self, element):
|
||||
return hasattr(element, "id") and self._id == element.id
|
||||
|
||||
def __ne__(self, element):
|
||||
return not self.__eq__(element)
|
||||
|
||||
# Private Methods
|
||||
def _execute(self, command, params=None):
|
||||
"""Executes a command against the underlying HTML element.
|
||||
|
||||
Args:
|
||||
command: The name of the command to _execute as a string.
|
||||
params: A dictionary of named parameters to send with the command.
|
||||
|
||||
Returns:
|
||||
The command's JSON response loaded into a dictionary object.
|
||||
"""
|
||||
if not params:
|
||||
params = {}
|
||||
params["id"] = self._id
|
||||
return self._parent.execute(command, params)
|
||||
|
||||
def find_element(self, by=By.ID, value=None) -> WebElement:
|
||||
"""Find an element given a By strategy and locator.
|
||||
|
||||
:Usage:
|
||||
::
|
||||
|
||||
element = element.find_element(By.ID, 'foo')
|
||||
|
||||
:rtype: WebElement
|
||||
"""
|
||||
by, value = self._parent.locator_converter.convert(by, value)
|
||||
return self._execute(Command.FIND_CHILD_ELEMENT, {"using": by, "value": value})["value"]
|
||||
|
||||
def find_elements(self, by=By.ID, value=None) -> List[WebElement]:
|
||||
"""Find elements given a By strategy and locator.
|
||||
|
||||
:Usage:
|
||||
::
|
||||
|
||||
element = element.find_elements(By.CLASS_NAME, 'foo')
|
||||
|
||||
:rtype: list of WebElement
|
||||
"""
|
||||
by, value = self._parent.locator_converter.convert(by, value)
|
||||
return self._execute(Command.FIND_CHILD_ELEMENTS, {"using": by, "value": value})["value"]
|
||||
|
||||
def __hash__(self) -> int:
|
||||
return int(md5_hash(self._id.encode("utf-8")).hexdigest(), 16)
|
||||
|
||||
def _upload(self, filename):
|
||||
fp = BytesIO()
|
||||
zipped = zipfile.ZipFile(fp, "w", zipfile.ZIP_DEFLATED)
|
||||
zipped.write(filename, os.path.split(filename)[1])
|
||||
zipped.close()
|
||||
content = encodebytes(fp.getvalue())
|
||||
if not isinstance(content, str):
|
||||
content = content.decode("utf-8")
|
||||
try:
|
||||
return self._execute(Command.UPLOAD_FILE, {"file": content})["value"]
|
||||
except WebDriverException as e:
|
||||
if "Unrecognized command: POST" in str(e):
|
||||
return filename
|
||||
if "Command not found: POST " in str(e):
|
||||
return filename
|
||||
if '{"status":405,"value":["GET","HEAD","DELETE"]}' in str(e):
|
||||
return filename
|
||||
raise
|
146
lib/python3.13/site-packages/selenium/webdriver/remote/websocket_connection.py
Executable file
146
lib/python3.13/site-packages/selenium/webdriver/remote/websocket_connection.py
Executable file
@ -0,0 +1,146 @@
|
||||
# Licensed to the Software Freedom Conservancy (SFC) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The SFC licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import json
|
||||
import logging
|
||||
from ssl import CERT_NONE
|
||||
from threading import Thread
|
||||
from time import sleep
|
||||
|
||||
from websocket import WebSocketApp # type: ignore
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class WebSocketConnection:
|
||||
_response_wait_timeout = 30
|
||||
_response_wait_interval = 0.1
|
||||
|
||||
_max_log_message_size = 9999
|
||||
|
||||
def __init__(self, url):
|
||||
self.callbacks = {}
|
||||
self.session_id = None
|
||||
self.url = url
|
||||
|
||||
self._id = 0
|
||||
self._messages = {}
|
||||
self._started = False
|
||||
|
||||
self._start_ws()
|
||||
self._wait_until(lambda: self._started)
|
||||
|
||||
def close(self):
|
||||
self._ws_thread.join(timeout=self._response_wait_timeout)
|
||||
self._ws.close()
|
||||
self._started = False
|
||||
self._ws = None
|
||||
|
||||
def execute(self, command):
|
||||
self._id += 1
|
||||
payload = self._serialize_command(command)
|
||||
payload["id"] = self._id
|
||||
if self.session_id:
|
||||
payload["sessionId"] = self.session_id
|
||||
|
||||
data = json.dumps(payload)
|
||||
logger.debug(f"-> {data}"[: self._max_log_message_size])
|
||||
self._ws.send(data)
|
||||
|
||||
self._wait_until(lambda: self._id in self._messages)
|
||||
response = self._messages.pop(self._id)
|
||||
|
||||
if "error" in response:
|
||||
raise Exception(response["error"])
|
||||
else:
|
||||
result = response["result"]
|
||||
return self._deserialize_result(result, command)
|
||||
|
||||
def add_callback(self, event, callback):
|
||||
event_name = event.event_class
|
||||
if event_name not in self.callbacks:
|
||||
self.callbacks[event_name] = []
|
||||
|
||||
def _callback(params):
|
||||
callback(event.from_json(params))
|
||||
|
||||
self.callbacks[event_name].append(_callback)
|
||||
return id(_callback)
|
||||
|
||||
on = add_callback
|
||||
|
||||
def remove_callback(self, event, callback_id):
|
||||
event_name = event.event_class
|
||||
if event_name in self.callbacks:
|
||||
for callback in self.callbacks[event_name]:
|
||||
if id(callback) == callback_id:
|
||||
self.callbacks[event_name].remove(callback)
|
||||
return
|
||||
|
||||
def _serialize_command(self, command):
|
||||
return next(command)
|
||||
|
||||
def _deserialize_result(self, result, command):
|
||||
try:
|
||||
_ = command.send(result)
|
||||
raise Exception("The command's generator function did not exit when expected!")
|
||||
except StopIteration as exit:
|
||||
return exit.value
|
||||
|
||||
def _start_ws(self):
|
||||
def on_open(ws):
|
||||
self._started = True
|
||||
|
||||
def on_message(ws, message):
|
||||
self._process_message(message)
|
||||
|
||||
def on_error(ws, error):
|
||||
logger.debug(f"error: {error}")
|
||||
ws.close()
|
||||
|
||||
def run_socket():
|
||||
if self.url.startswith("wss://"):
|
||||
self._ws.run_forever(sslopt={"cert_reqs": CERT_NONE}, suppress_origin=True)
|
||||
else:
|
||||
self._ws.run_forever(suppress_origin=True)
|
||||
|
||||
self._ws = WebSocketApp(self.url, on_open=on_open, on_message=on_message, on_error=on_error)
|
||||
self._ws_thread = Thread(target=run_socket)
|
||||
self._ws_thread.start()
|
||||
|
||||
def _process_message(self, message):
|
||||
message = json.loads(message)
|
||||
logger.debug(f"<- {message}"[: self._max_log_message_size])
|
||||
|
||||
if "id" in message:
|
||||
self._messages[message["id"]] = message
|
||||
|
||||
if "method" in message:
|
||||
params = message["params"]
|
||||
for callback in self.callbacks.get(message["method"], []):
|
||||
callback(params)
|
||||
|
||||
def _wait_until(self, condition):
|
||||
timeout = self._response_wait_timeout
|
||||
interval = self._response_wait_interval
|
||||
|
||||
while timeout > 0:
|
||||
result = condition()
|
||||
if result:
|
||||
return result
|
||||
else:
|
||||
timeout -= interval
|
||||
sleep(interval)
|
Reference in New Issue
Block a user