update: tweaks on APIs
This commit is contained in:
+1
-1
@@ -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" },
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user