Best Python code snippet using robotframework
wb_actions.py
Source:wb_actions.py  
...36            self._wait_until_keyword_returns_true(timeout, timestr_to_secs(timeout)/10, "is_text_present", text)               37        except Exception, err:38            if not 'did not become true' in str(err):39                raise40            timestr = secs_to_timestr(timestr_to_secs(timeout))41            raise AssertionError("Text '%s' did not appear in '%s'" 42                                  % (text, timestr))43    def wait_until_page_contains_element(self, locator, timeout):44        """45        Waits until `element` appears on current page or `timeout` expires.46        """47        try:48            self._wait_until_keyword_returns_true(timeout, timestr_to_secs(timeout)/10, "is_element_present", locator)               49        except Exception, err:50            if not 'did not become true' in str(err):51                raise52            timestr = secs_to_timestr(timestr_to_secs(timeout))53            raise AssertionError("Element '%s' did not appear in '%s'" 54                                  % (locator, timestr))55        56    def wait_for_page_to_load(self,timeout):57        """58        Waits for a new page to load.59        Over-rided the Robot Framework built-in keyword to fix the timing issues.60        """61        timeout = timestr_to_secs(timeout)62        self._selenium.wait_for_page_to_load(timeout*1000)63    def wait_until_element_visible(self, locator, timeout):64        """65        Waits until the element is visble. Can be used to wait for ajax calls. 66        """67        try:68            self._wait_until_keyword_returns_true(timeout, timestr_to_secs(timeout)/10, "is_visible", locator)               69        except Exception, err:70            if not 'did not become true' in str(err):71                raise72            timestr = secs_to_timestr(timestr_to_secs(timeout))73            raise AssertionError("Element '%s' did not appear in '%s'" 74                                  % (locator, timestr))75    def execute_script(self, script):76        browser = self._selenium.browserStartCommand 77        if not browser in ['*iexplore', '*iehta', '*chrome', '*firefox']:78            raise DataError("Keyword 'Execute Script' can only be used with '*chrome', '*iexplore', '*iehta', '*firefox' browsers")79        self._info("Executing Javascript '%s'" % (script))80        if browser in ['*iexplore', '*iehta']:81            self._selenium.run_script(script)82        else:83            self.do_command("executeScript", [script,])84    85    def _wait_until_keyword_returns_true(self, timeout, retry_interval, name, *args):86        """Helper method for wait_until_page_contains"""87        timeout = timestr_to_secs(timeout)88        retry_interval = timestr_to_secs(retry_interval)89        starttime = time.time()90        while time.time() - starttime < timeout:91            try:92                self._info("Waiting %s for condition '%s' to be true." 93                    % (secs_to_timestr(timestr_to_secs(retry_interval)), args[0]))  94                if not BuiltIn.run_keyword(BuiltIn(), name, *args):95                    time.sleep(retry_interval)96                else:97                    self._info("Return True in '%s' " % (secs_to_timestr(time.time() - timestr_to_secs(starttime))))98                    return True              99            except Exception:100                time.sleep(retry_interval)101        raise AssertionError("did not become true")102    def _wait_for_asycronous_callback(self, inputlocator):103        """104        Perform an asynchronous operation on element `inputlocator`105        and call `callback` upon asynchronous completion. This function106        is useful for selenium calls which don't immediately return107        response codes108        """109        splitstring = inputlocator.split(":")110        locator = splitstring[0]111        pattern = splitstring[1]...config.py
Source:config.py  
...89    def _parse_value(self, value):90        value = str(value)91        return timestr_to_secs(value) if value else None92    def __str__(self):93        return secs_to_timestr(self._value)94class LogLevelEntry(Entry):95    """Log level to be stored in :py:class:`Configuration`.96    Given string must be one of 'TRACE', 'DEBUG', 'INFO', 'WARN' or 'NONE' case97    insensitively.98    """99    LEVELS = ('TRACE', 'DEBUG', 'INFO', 'WARN', 'NONE')100    def _parse_value(self, value):101        value = str(value).upper()102        if value not in self.LEVELS:103            raise ConfigurationException("Invalid log level '%s'." % value)104        return value105class NewlineEntry(Entry):106    """New line sequence to be stored in :py:class:`Configuration`.107    Following conversion are performed on the given string:...application.py
Source:application.py  
...75        | Wait Until Application Has Stopped | calc | # waits until calc.exe process does not exist |76        """77        timeout = timestr_to_secs(timeout)78        Wait.until_true(lambda: not Process.GetProcessesByName(name), timeout,...__init__.py
Source:__init__.py  
...69    def disable_implicit_wait_for_primefaces(self):70        self.enable_implicit_wait_for_primefaces(False)7172    def get_implicit_wait_timeout(self):73        return secs_to_timestr(self.timeout)7475    def set_implicit_wait_timeout(self, seconds):76        old_timeout = self.get_implicit_wait_timeout()77        self.timeout = timestr_to_secs(seconds)78        self._selib._element_finder.timeout = self.timeout79        return old_timeout8081    def wait_for_primefaces(self, timeout=None, message=None):8283        if timeout:84            timeoutSecs = timestr_to_secs(timeout)85        else:86            timeoutSecs = self.timeout87
...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
