Пример #1
0
    def __init__(self, resources):
        """
        - ``resources``:
          semicolon separated list of python packages to scan for robotframework resource files
        """

        DynamicCore.__init__(self, [])
        self.resources = []
        try:
            self.rf = BuiltIn()
        except RobotNotRunningError:
            pass
        self.modules = self._find_modules()
        for resource in resources.split(";"):
            if resource in self.modules:
                resource_files = self._find_resources(self.modules[resource])
                if resource_files:
                    for resource_file in resource_files:
                        try:
                            self.rf.import_resource(resource_file)
                        except RobotNotRunningError:
                            pass
                        self.resources.append(resource_file)
                else:
                    logger.warn(
                        f"Module {resource} did't contain any resource files")
            else:
                logger.warn(
                    f"Module {resource} doesn't contain resource directory: {self.RESOURCE_PATH}"
                )
Пример #2
0
    def __init__(
        self,
        visible: bool = True,
        timeout: int = 30,
        wait_time: float = 0.5,
        wait_time_after_write: float = 0.0,
        img_folder: str = ".",
        run_on_failure_keyword: str = "Take Screenshot",
    ) -> None:
        """
        By default the emulator visibility is set to visible=True.
        In this case test cases are executed using wc3270 (Windows) or x3270 (Linux/MacOSX).
        You can change this by setting visible=False.
        Then test cases are run using ws3720 (Windows) or s3270 (Linux/MacOS).
        This is useful when test cases are run in a CI/CD-pipeline and there is no need for a graphical user interface.

        Timeout, waits and screenshot folder are set on library import as shown above.
        However, they can be changed during runtime. To modify the ``wait_time``, see `Change Wait Time`,
        to modify the ``img_folder``, see `Set Screenshot Folder`,
        and to modify the ``timeout``, see the `Change Timeout` keyword.

        By default, Mainframe3270 will take a screenshot on failure.
        You can overwrite this to run any other keyword by setting the ``run_on_failure_keyword`` option.
        If you pass ``None`` to this argument, no keyword will be run.
        To change the ``run_on_failure_keyword`` during runtime, see `Register Run On Failure Keyword`.
        """
        self._running_on_failure_keyword = False
        self.register_run_on_failure_keyword(run_on_failure_keyword)
        libraries = [
            x3270(visible, timeout, wait_time, wait_time_after_write,
                  img_folder)
        ]
        DynamicCore.__init__(self, libraries)
Пример #3
0
    def __init__(self, timeout="10s", enable_playwright_debug: bool = False):
        """Browser library can be taken into use with optional arguments:

        - ``timeout``:
          Timeout for keywords that operate on elements. The keywords will wait
          for this time for the element to appear into the page.
        - ``enable_playwright_debug``:
          Enable low level debug information from the playwright tool. Mainly
          Useful for the library developers and for debugging purposes.
        """
        self.ROBOT_LIBRARY_LISTENER = self
        # This is more explicit than to have all the libraries be referenceable when they don't need it.
        self.browser_control = Control(self)
        self.promises = Promises(self)
        libraries = [
            self.browser_control,
            Evaluation(self),
            Input(self),
            Getters(self),
            PlaywrightState(self),
            Network(self),
            self.promises,
            Waiter(self),
            WebAppState(self),
        ]
        self.playwright = Playwright(timeout, enable_playwright_debug)
        DynamicCore.__init__(self, libraries)
Пример #4
0
 def __init__(self, arg=None):
     """Library init doc."""
     components = [librarycomponents,
                   librarycomponents.Names(),
                   librarycomponents.Arguments(),
                   librarycomponents.DocsAndTags()]
     DynamicCore.__init__(self, components)
     self.instance_attribute = 'not keyword'
Пример #5
0
    def __init__(
        self,
        timeout: timedelta = timedelta(seconds=10),
        enable_playwright_debug: bool = False,
        auto_closing_level: AutoClosingLevel = AutoClosingLevel.TEST,
        retry_assertions_for: timedelta = timedelta(seconds=1),
        run_on_failure: str = "Take Screenshot",
    ):
        """Browser library can be taken into use with optional arguments:

        - ``timeout`` <str>
          Timeout for keywords that operate on elements. The keywords will wait
          for this time for the element to appear into the page. Defaults to "10s" => 10 seconds.
        - ``enable_playwright_debug`` <bool>
          Enable low level debug information from the playwright tool. Mainly
          Useful for the library developers and for debugging purposes.
        - ``auto_closing_level`` < ``SUITE`` | ``TEST`` | ``MANUAL`` >
          Configure context and page automatic closing. Default is after each test.
          Other options are SUITE for closing after each suite and MANUAL
          for no automatic closing.
        - ``retry_assertions_for`` <str>
          Timeout for retrying assertions on keywords before failing the keywords.
          This timeout starts counting from the first failure.
          Global ``timeout`` will still be in effect.
          This allows stopping execution faster to assertion failure when element is found fast.
        - ``run_on_failure`` <str>
          Sets the keyword to execute in case of a failing Browser keyword.
          It can be the name of any keyword that does not have any mandatory argument.
          If no extra action should be done after a failure, set it to ``None`` or any other robot falsy value.
        """
        self.timeout = self.convert_timeout(timeout)
        self.retry_assertions_for = self.convert_timeout(retry_assertions_for)
        self.ROBOT_LIBRARY_LISTENER = self
        self._execution_stack: List[object] = []
        self._running_on_failure_keyword = False
        self._pause_on_failure = set()
        self.run_on_failure_keyword = (None if is_falsy(run_on_failure) else
                                       run_on_failure)
        self._unresolved_promises: Set[Future] = set()
        self._playwright_state = PlaywrightState(self)
        libraries = [
            self._playwright_state,
            Control(self),
            Cookie(self),
            Devices(self),
            Evaluation(self),
            Interaction(self),
            Getters(self),
            Network(self),
            RunOnFailureKeywords(self),
            Promises(self),
            Waiter(self),
            WebAppState(self),
        ]
        self.playwright = Playwright(self, enable_playwright_debug)
        self._auto_closing_level = auto_closing_level
        self.current_arguments = ()
        DynamicCore.__init__(self, libraries)
 def __init__(self):
     self._database = None
     libraries = [
         KeePassDatabase(self),
         KeePassEntry(self),
         KeePassEntries(self),
         KeePassGroup(self),
         KeePassGroups(self)
     ]
     DynamicCore.__init__(self, libraries)
 def _get_intro_documentation(self):
     intro = DynamicCore.get_keyword_documentation(self, "__intro__")
     for plugin_doc in self._parse_plugin_doc():
         intro = f"{intro}\n\n"
         intro = f"{intro}= Plugin: {plugin_doc.name} =\n\n"
         intro = f"{intro}{plugin_doc.doc}"
     return intro
Пример #8
0
 def _get_intro_documentation(self):
     intro = DynamicCore.get_keyword_documentation(self, '__intro__')
     for plugin_doc in self._parse_plugin_doc():
         intro += '\n\n'
         intro = intro + '= Plugin: %s =' % plugin_doc.name + '\n\n'
         intro = intro + plugin_doc.doc
     return self._create_toc(intro)
Пример #9
0
 def run_keyword(self, name, args, kwargs):
     self._running_keyword = name
     try:
         return DynamicCore.run_keyword(self, name, args, kwargs)
     except Exception:
         self.failure_occurred()
         raise
     finally:
         self._running_keyword = None
Пример #10
0
    def __init__(
        self,
        timeout="10s",
        enable_playwright_debug: bool = False,
        auto_closing_level: AutoClosingLevel = AutoClosingLevel.TEST,
        assertion_polling_enabled: bool = True,
    ):
        """Browser library can be taken into use with optional arguments:

        - ``timeout`` <str>
          Timeout for keywords that operate on elements. The keywords will wait
          for this time for the element to appear into the page. Defaults to "10s" => 10 seconds.
        - ``enable_playwright_debug`` <bool>
          Enable low level debug information from the playwright tool. Mainly
          Useful for the library developers and for debugging purposes.
        - ``auto_closing_level`` <SUITE|TEST|MANUAL>
          Configure context and page automatic closing. Default is after each test.
          Other options are SUITE for closing after each suite and MANUAL
          for no automatic closing.
        - ``assertion_polling_enabled`` <bool>
          Disable assertion polling by setting this flag to false.
        """
        self.timeout = timeout
        self.assertion_polling_enabled = assertion_polling_enabled
        self.ROBOT_LIBRARY_LISTENER = self
        self._execution_stack: List[object] = []
        self._unresolved_promises: Set[Future] = set()
        self._playwright_state = PlaywrightState(self)
        libraries = [
            Control(self),
            Cookie(self),
            Devices(self),
            Evaluation(self),
            Interaction(self),
            Getters(self),
            self._playwright_state,
            Network(self),
            Promises(self),
            Waiter(self),
            WebAppState(self),
        ]
        self.playwright = Playwright(self, enable_playwright_debug)
        self._auto_closing_level = auto_closing_level
        DynamicCore.__init__(self, libraries)
Пример #11
0
    def __init__(
        self,
        timeout="10s",
        enable_playwright_debug: bool = False,
        auto_closing_level: AutoClosingLevel = AutoClosingLevel.TEST,
    ):
        """Browser library can be taken into use with optional arguments:

        - ``timeout`` <str>
          Timeout for keywords that operate on elements. The keywords will wait
          for this time for the element to appear into the page. Defaults to "10s" => 10 seconds.
        - ``enable_playwright_debug`` <bool>
          Enable low level debug information from the playwright tool. Mainly
          Useful for the library developers and for debugging purposes.
        - ``auto_closing_level`` <SUITE|TEST|MANUAL>
          Configure context and page automatic closing. Default is after each test.
          Other options are SUITE for closing after each suite and MANUAL
          for no automatic closing.
        """
        self.timeout = timeout
        self.ROBOT_LIBRARY_LISTENER = self
        self._execution_stack: List[object] = []
        # This is more explicit than to have all the libraries be referenceable when they don't need it.
        self.browser_control = Control(self)
        self.promises = Promises(self)
        self.getters = Getters(self)
        self.playwright_state = PlaywrightState(self)
        libraries = [
            self.browser_control,
            Cookie(self),
            Devices(self),
            Evaluation(self),
            Interaction(self),
            self.getters,
            self.playwright_state,
            Network(self),
            self.promises,
            Waiter(self),
            WebAppState(self),
        ]
        self.playwright = Playwright(self, enable_playwright_debug)
        self._auto_closing_level = auto_closing_level
        DynamicCore.__init__(self, libraries)
Пример #12
0
 def get_keyword_documentation(self, name):
     doc = DynamicCore.get_keyword_documentation(self, name)
     if name == "__intro__":
         doc = doc.replace("%ASSERTION_TABLE%", AssertionOperator.__doc__)
         doc = doc.replace("%AUTO_CLOSING_LEVEL%", AutoClosingLevel.__doc__)
     elif name == "set_assertion_formatters":
         doc = doc.replace('"Keyword Name"', '"Get Text"')
         doc = f"{doc}\n    | ${{value}} =    `Get Text`    //div    ==    ${{SPACE}}Expected${{SPACE * 2}}Text"
         doc = f"{doc}\n    | Should Be Equal    ${{value}}    Expected Text\n"
     return doc
Пример #13
0
    def __init__(self):
        DynamicCore.__init__(self, [])
        self.ROBOT_LIBRARY_LISTENER = self

        # inputs
        self.descriptor_file = None
        self.suite_source = None
        self.parsed_descriptor = None

        # Suite config
        self.deployment_name = None
        self.orchestrator = None

        # Test case config
        self.sut = SUT(None, None, None)
        self.deployment_options = {
            'SKIP_UNDEPLOY': False,
            'USE_DEPLOYMENT': None
        }
        self.test_volume = None
        self.sidecar = None
        self.services = []
        self.containers = []

        # keep state of test
        self.context = None
        self.test_cases = []
        self.current_keywords = []
        self.fatal_error = False
        self.validation_attempted = False

        try:
            self.deployment_options['USE_DEPLOYMENT'] = \
                (Settings.use_deployment or
                 BuiltIn().get_variable_value("${USE_DEPLOYMENT}") or '').strip('\'')
            if (self.deployment_options['USE_DEPLOYMENT']
                    or BuiltIn().get_variable_value("${SKIP_UNDEPLOY}")
                    or Settings.skip_undeploy):
                self.deployment_options['SKIP_UNDEPLOY'] = True
        except RobotNotRunningError:
            pass
Пример #14
0
 def run_keyword(self, name, args, kwargs=None):
     try:
         return DynamicCore.run_keyword(self, name, args, kwargs)
     except AssertionError as e:
         self.keyword_error()
         if self._pause_on_failure:
             sys.__stdout__.write(f"\n[ FAIL ] {e}")
             sys.__stdout__.write(
                 "\n[Paused on failure] Press Enter to continue..\n")
             sys.__stdout__.flush()
             input()
         raise e
 def run_keyword(self, name: str, args: tuple, kwargs: dict):
     try:
         return DynamicCore.run_keyword(self, name, args, kwargs)
     except Exception:
         self.failure_occurred()
         raise
    def __init__(
        self,
        timeout=timedelta(seconds=5),
        implicit_wait=timedelta(seconds=0),
        run_on_failure="Capture Page Screenshot",
        screenshot_root_directory: Optional[str] = None,
        plugins: Optional[str] = None,
        event_firing_webdriver: Optional[str] = None,
    ):
        """SeleniumLibrary can be imported with several optional arguments.

        - ``timeout``:
          Default value for `timeouts` used with ``Wait ...`` keywords.
        - ``implicit_wait``:
          Default value for `implicit wait` used when locating elements.
        - ``run_on_failure``:
          Default action for the `run-on-failure functionality`.
        - ``screenshot_root_directory``:
          Path to folder where possible screenshots are created or EMBED.
          See `Set Screenshot Directory` keyword for further details about EMBED.
          If not given, the directory where the log file is written is used.
        - ``plugins``:
          Allows extending the SeleniumLibrary with external Python classes.
        - ``event_firing_webdriver``:
          Class for wrapping Selenium with
          [https://seleniumhq.github.io/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.event_firing_webdriver.html#module-selenium.webdriver.support.event_firing_webdriver|EventFiringWebDriver]
        """
        self.timeout = _convert_timeout(timeout)
        self.implicit_wait = _convert_timeout(implicit_wait)
        self.speed = 0.0
        self.run_on_failure_keyword = RunOnFailureKeywords.resolve_keyword(
            run_on_failure)
        self._running_on_failure_keyword = False
        self.screenshot_root_directory = screenshot_root_directory
        self._resolve_screenshot_root_directory()
        self._element_finder = ElementFinder(self)
        self._plugin_keywords = []
        libraries = [
            AlertKeywords(self),
            BrowserManagementKeywords(self),
            CookieKeywords(self),
            ElementKeywords(self),
            FormElementKeywords(self),
            FrameKeywords(self),
            JavaScriptKeywords(self),
            RunOnFailureKeywords(self),
            ScreenshotKeywords(self),
            SelectElementKeywords(self),
            TableElementKeywords(self),
            WaitingKeywords(self),
            WindowKeywords(self),
        ]
        self.ROBOT_LIBRARY_LISTENER = LibraryListener()
        self._running_keyword = None
        self.event_firing_webdriver = None
        if is_truthy(event_firing_webdriver):
            self.event_firing_webdriver = self._parse_listener(
                event_firing_webdriver)
        self._plugins = []
        if is_truthy(plugins):
            plugin_libs = self._parse_plugins(plugins)
            self._plugins = plugin_libs
            libraries = libraries + plugin_libs
        self._drivers = WebDriverCache()
        DynamicCore.__init__(self, libraries)
Пример #17
0
 def run_keyword(self, name, args, kwargs=None):
     try:
         return DynamicCore.run_keyword(self, name, args, kwargs)
     except AssertionError as e:
         self.keyword_error()
         raise e
 def __init__(self):
     DynamicCore.__init__(self, [])
 def __init__(self, arg: str):
     DynamicCore.__init__(self, [])
     self.instance_attribute = 'not keyword'
     self.arg = arg
Пример #20
0
 def get_keyword_documentation(self, name):
     doc = DynamicCore.get_keyword_documentation(self, name)
     if name == "__intro__":
         doc = doc.replace("%ASSERTION_TABLE%", AssertionOperator.__doc__)
         doc = doc.replace("%AUTO_CLOSING_LEVEL%", AutoClosingLevel.__doc__)
     return doc
Пример #21
0
    def __init__(
        self,
        timeout: timedelta = timedelta(seconds=10),
        enable_playwright_debug: bool = False,
        auto_closing_level: AutoClosingLevel = AutoClosingLevel.TEST,
        retry_assertions_for: timedelta = timedelta(seconds=1),
        run_on_failure: str = "Take Screenshot",
        external_browser_executable: Optional[Dict[SupportedBrowsers,
                                                   str]] = None,
        jsextension: Optional[str] = None,
        enable_presenter_mode: bool = False,
    ):
        """Browser library can be taken into use with optional arguments:

        - ``timeout`` <str>
          Timeout for keywords that operate on elements. The keywords will wait
          for this time for the element to appear into the page. Defaults to "10s" => 10 seconds.
        - ``enable_playwright_debug`` <bool>
          Enable low level debug information from the playwright tool. Mainly
          Useful for the library developers and for debugging purposes.
        - ``auto_closing_level`` < ``TEST`` | ``SUITE`` | ``MANUAL`` >
          Configure context and page automatic closing. Default is ``TEST``,
          for more details, see `AutoClosingLevel`
        - ``retry_assertions_for`` <str>
          Timeout for retrying assertions on keywords before failing the keywords.
          This timeout starts counting from the first failure.
          Global ``timeout`` will still be in effect.
          This allows stopping execution faster to assertion failure when element is found fast.
        - ``run_on_failure`` <str>
          Sets the keyword to execute in case of a failing Browser keyword.
          It can be the name of any keyword that does not have any mandatory argument.
          If no extra action should be done after a failure, set it to ``None`` or any other robot falsy value.
        - ``external_browser_executable`` <Dict <SupportedBrowsers, Path>>
          Dict mapping name of browser to path of executable of a browser.
          Will make opening new browsers of the given type use the set executablePath.
          Currently only configuring of `chromium` to a separate executable (chrome,
          chromium and Edge executables all work with recent versions) works.
        - ``jsextension`` <str>
          Path to Javascript module exposed as extra keywords. Module must be in CommonJS.
        - ``enable_presenter_mode`` <bool>
          Automatic highlights to interacted components, slowMo and a small pause at the end.
        """
        self.timeout = self.convert_timeout(timeout)
        self.retry_assertions_for = self.convert_timeout(retry_assertions_for)
        self.ROBOT_LIBRARY_LISTENER = self
        self._execution_stack: List[dict] = []
        self._running_on_failure_keyword = False
        self._pause_on_failure: Set["Browser"] = set()
        self.run_on_failure_keyword = (None if is_falsy(run_on_failure) else {
            "name": run_on_failure,
            "args": ()
        })
        self.external_browser_executable: Dict[SupportedBrowsers, str] = (
            external_browser_executable or {})
        self._unresolved_promises: Set[Future] = set()
        self._playwright_state = PlaywrightState(self)
        libraries = [
            self._playwright_state,
            Control(self),
            Cookie(self),
            Crawling(self),
            Devices(self),
            Evaluation(self),
            Interaction(self),
            Getters(self),
            Network(self),
            RunOnFailureKeywords(self),
            Promises(self),
            Waiter(self),
            WebAppState(self),
        ]
        self.playwright = Playwright(self, enable_playwright_debug)
        self._auto_closing_level = auto_closing_level
        self.current_arguments = ()
        if jsextension is not None:
            libraries.append(self._initialize_jsextension(jsextension))
        self.presenter_mode = enable_presenter_mode
        DynamicCore.__init__(self, libraries)
 def __init__(self) -> None:
     libraries = [Library1(), Library2()]
     DynamicCore.__init__(self, libraries)
Пример #23
0
 def __init__(self):
     self.benchmarks = {}
     DynamicCore.__init__(self, [])
Пример #24
0
 def get_keyword_tags(self, name):
     tags = list(DynamicCore.get_keyword_tags(self, name))
     if name in self._plugin_keywords:
         tags.append('plugin')
     return tags
Пример #25
0
 def get_keyword_documentation(self, name):
     if name == '__intro__':
         return self._get_intro_documentation()
     return DynamicCore.get_keyword_documentation(self, name)
 def get_keyword_tags(self, name: str) -> list:
     tags = list(DynamicCore.get_keyword_tags(self, name))
     if name in self._plugin_keywords:
         tags.append("plugin")
     return tags
 def get_keyword_documentation(self, name: str) -> str:
     if name == "__intro__":
         return self._get_intro_documentation()
     return DynamicCore.get_keyword_documentation(self, name)
Пример #28
0
 def __init__(self: "Helpers") -> None:
     DynamicCore.__init__(self, [])
 def _store_plugin_keywords(self, plugin):
     dynamic_core = DynamicCore([plugin])
     self._plugin_keywords.extend(dynamic_core.get_keyword_names())
Пример #30
0
 def __init__(self):
     self._keyword_formatters = {}
     DynamicCore.__init__(self, [Formatter(self)])