Python Programming _selenium2library Source Analysis

Source: Internet
Author: User

[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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.