fix: 'Action' as regular Exception
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
from abc import abstractmethod, ABCMeta
|
from abc import abstractmethod, ABCMeta
|
||||||
class Unavailable(BaseException): pass
|
class Unavailable(Exception): pass
|
||||||
class NotAllowed(BaseException): pass
|
class NotAllowed(Exception): pass
|
||||||
|
|
||||||
class Action(BaseException, metaclass=ABCMeta):
|
class Action(Exception, metaclass=ABCMeta):
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
super().__init__(*args)
|
super().__init__(*args)
|
||||||
|
|
||||||
@@ -28,14 +28,13 @@ class ActionFlow:
|
|||||||
|
|
||||||
if self.on[index]: raise Unavailable(name)
|
if self.on[index]: raise Unavailable(name)
|
||||||
if self.on[index] is None: raise NotAllowed(name)
|
if self.on[index] is None: raise NotAllowed(name)
|
||||||
value = self.actions[index].prepare()
|
self.on[index] = bool(self.actions[index].prepare())
|
||||||
self.on[index] = bool(value)
|
|
||||||
|
|
||||||
def react(self):
|
def react(self):
|
||||||
for index in self.indices.values():
|
for index in self.indices.values():
|
||||||
if (self.on[index]):
|
if (self.on[index]):
|
||||||
self.on[index] = False
|
self.on[index] = None
|
||||||
self.actions[index].perform()
|
self.on[index] = bool(self.actions[index].perform())
|
||||||
|
|
||||||
def index(self, action: type[Action]) -> int:
|
def index(self, action: type[Action]) -> int:
|
||||||
name = action.__name__
|
name = action.__name__
|
||||||
|
|||||||
@@ -52,4 +52,4 @@ const RemoteProceduralCall = {
|
|||||||
|
|
||||||
window.LogRecord = LogRecord;
|
window.LogRecord = LogRecord;
|
||||||
window.Rpc2 = RemoteProceduralCall;
|
window.Rpc2 = RemoteProceduralCall;
|
||||||
main(...arguments); // entrypoint to user-defined (async) main stub of the script
|
main(...arguments); // user-defined code
|
||||||
@@ -10,8 +10,7 @@ from selenium.webdriver.support.wait import WebDriverWait
|
|||||||
from selenium.common.exceptions import StaleElementReferenceException, TimeoutException
|
from selenium.common.exceptions import StaleElementReferenceException, TimeoutException
|
||||||
|
|
||||||
driver: WebDriver|None = None
|
driver: WebDriver|None = None
|
||||||
attempts, timeout, interval = int(), float(), float()
|
attempts, timeout, interval, identity = int(), float(), float(), None
|
||||||
identity = ''.join(random.choices(string.ascii_uppercase + string.digits, k=8))
|
|
||||||
|
|
||||||
def until(condition: typing.Callable[[WebDriver], bool], watch=True):
|
def until(condition: typing.Callable[[WebDriver], bool], watch=True):
|
||||||
try:
|
try:
|
||||||
@@ -70,7 +69,8 @@ def click(selector: str|WebElement, wait=True, condition=False):
|
|||||||
except: break
|
except: break
|
||||||
|
|
||||||
def setup(a: WebDriver, b: int, c: float, d: float):
|
def setup(a: WebDriver, b: int, c: float, d: float):
|
||||||
global driver, attempts, timeout, interval
|
global identity, driver, attempts, timeout, interval
|
||||||
|
identity = ''.join(random.choices(string.ascii_uppercase + string.digits, k=8))
|
||||||
driver = a
|
driver = a
|
||||||
attempts = b
|
attempts = b
|
||||||
timeout = c
|
timeout = c
|
||||||
|
|||||||
Reference in New Issue
Block a user