[Package] Keywords
All keywords encapsulated
[Class] _waiting.py
Wait for the condition of the function to judge, replace sleep, in order to execute more use cases with conditional logic, can effectively save the execution wait time, quickly locate the problem
_wait_until (self, timeout, error, function, *args)
Overview: Until function (*args) is true, return None, false to return error, time-out timeout
Parameters:
Error: Initializing to timeout exception
function: Conditional judgment, return TRUE or False
Return:none or Error
1 def _wait_until (self, timeout, Error, function, *args): 2 error = Error.re Place ( " <TIMEOUT> " , Self._format_timeout (timeout) 3 def< /span> Wait_func (): 4 return None if function (*args) else error 5 self._wait_until_no_error (timeout, wait_func)
_wait_until_no_error (self, timeout, wait_func, *args)
Overview: Return when Wait_func (*args) is false, timeout throws a timeout exception
1 def_wait_until_no_error (self, timeout,Wait_func,* args):2Timeout = robot.utils.timestr_to_secs (timeout)ifTimeout is notNoneElseSelf._timeout_in_secs3MaxTime = Time.time () +Timeout4 whileTrue:5 Timeout_error = wait_func (*args) 6 if notTimeout_error:return7 ifTime.time () >MaxTime:8 Raiseassertionerror (timeout_error)9Time.sleep (0.2)
The final call is _wait_until_no_error (self, timeout, wait_func, *args). In the layer call, the Python syntax used, one is the function nesting, but "everything is the object", function can also do parameter passing
Python Programming _selenium2library Source Analysis