update: tweaks on APIs

This commit is contained in:
2026-08-14 11:53:41 +08:00
parent bfb45a971e
commit 31a3167cff
2 changed files with 4 additions and 8 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "common"
description = "Commonly reusable code"
version = "0.1.20"
version = "0.1.21"
requires-python = ">=3.13"
authors = [
{ name="BreakerBear", email="breakerbear@autistic.men" },
+3 -7
View File
@@ -1,6 +1,5 @@
import random
import string
import typing
from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.remote.webelement import WebElement
@@ -12,12 +11,9 @@ from selenium.common.exceptions import StaleElementReferenceException, NoAlertPr
driver: WebDriver|None = None
unique, parameters = None, dict()
def until(condition: typing.Callable[[WebDriver], bool], watch=True):
try:
WebDriverWait(driver, parameters.get('timeout', 0)).until(condition)
except (TimeoutException, StaleElementReferenceException):
pass
if watch: WebDriverWait(driver, parameters.get('timeout', 0)).until_not(condition)
def until(condition, timeout=None):
try: return WebDriverWait(driver, timeout or parameters.get('timeout') or 0).until(condition)
except: pass
def sleep(seconds: float):
try: driver.switch_to.alert