update: tweaks on APIs
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
[project]
|
[project]
|
||||||
name = "common"
|
name = "common"
|
||||||
description = "Commonly reusable code"
|
description = "Commonly reusable code"
|
||||||
version = "0.1.20"
|
version = "0.1.21"
|
||||||
requires-python = ">=3.13"
|
requires-python = ">=3.13"
|
||||||
authors = [
|
authors = [
|
||||||
{ name="BreakerBear", email="breakerbear@autistic.men" },
|
{ name="BreakerBear", email="breakerbear@autistic.men" },
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
import typing
|
|
||||||
|
|
||||||
from selenium.webdriver.remote.webdriver import WebDriver
|
from selenium.webdriver.remote.webdriver import WebDriver
|
||||||
from selenium.webdriver.remote.webelement import WebElement
|
from selenium.webdriver.remote.webelement import WebElement
|
||||||
@@ -12,12 +11,9 @@ from selenium.common.exceptions import StaleElementReferenceException, NoAlertPr
|
|||||||
driver: WebDriver|None = None
|
driver: WebDriver|None = None
|
||||||
unique, parameters = None, dict()
|
unique, parameters = None, dict()
|
||||||
|
|
||||||
def until(condition: typing.Callable[[WebDriver], bool], watch=True):
|
def until(condition, timeout=None):
|
||||||
try:
|
try: return WebDriverWait(driver, timeout or parameters.get('timeout') or 0).until(condition)
|
||||||
WebDriverWait(driver, parameters.get('timeout', 0)).until(condition)
|
except: pass
|
||||||
except (TimeoutException, StaleElementReferenceException):
|
|
||||||
pass
|
|
||||||
if watch: WebDriverWait(driver, parameters.get('timeout', 0)).until_not(condition)
|
|
||||||
|
|
||||||
def sleep(seconds: float):
|
def sleep(seconds: float):
|
||||||
try: driver.switch_to.alert
|
try: driver.switch_to.alert
|
||||||
|
|||||||
Reference in New Issue
Block a user