Пример #1
0
    def __init__(self, implicit_wait=15.0, **kwargs):
        # pylint: disable=line-too-long
        """ExtendedSelenium2Library can be imported with optional arguments.

        Arguments:
        - ``timeout``: The maximum value to wait for all waiting actions. (Default 5.0)
                       It can be set later with `Set Selenium Timeout`.
                       See `introduction` for more information about ``timeout``.
        - ``implicit_wait``: The maximum implicit timeout value to wait when looking
                             for elements. (Default 15.0)
                             It can be later set with `Set Selenium Implicit Wait`.
                             See [http://goo.gl/8ePMo6|WebDriver: Advanced Usage]
                             section of the SeleniumHQ documentation for more information about
                             WebDriver's implicit wait functionality.
        - ``run_on_failure``: The name of a keyword (from any available libraries) to execute
                              when a ExtendedSelenium2Library keyword fails. By default
                              `Capture Page Screenshot` will be used to take a screenshot of
                              the current page.
                              Using the value "Nothing" will disable this feature altogether.
                              See `Register Keyword To Run On Failure` keyword for
                              more information about this functionality.
        - ``screenshot_root_directory``: The default root directory that screenshots should be
                                         stored in. If not provided, the default directory will be
                                         where [http://goo.gl/lES6WM|Robot Framework] places its
                                         logfile.
        - ``block_until_page_ready``: A boolean flag to block the execution until
                                      the page is ready. (Default True)
        - ``browser_breath_delay``: The delay value in seconds to give the browser enough time to
                                    complete current execution. (Default 0.05)
        - ``ensure_jq``: A boolean flag to ensure jQuery library is loaded on the page.
                         ``sizzle`` locator strategy will depend on this flag. (Default True)
        - ``poll_frequency``: The delay value in seconds to retry the next step. (Default 0.2)

        Examples:
        | Library `|` ExtendedSelenium2Library `|` 15                                            | # Sets default timeout to 15 seconds                                       |
        | Library `|` ExtendedSelenium2Library `|` 0 `|` 5                                       | # Sets default timeout to 0 seconds and default implicit_wait to 5 seconds |
        | Library `|` ExtendedSelenium2Library `|` 5 `|` run_on_failure=Log Source               | # Sets default timeout to 5 seconds and runs `Log Source` on failure       |
        | Library `|` ExtendedSelenium2Library `|` implicit_wait=5 `|` run_on_failure=Log Source | # Sets default implicit_wait to 5 seconds and runs `Log Source` on failure |
        | Library `|` ExtendedSelenium2Library `|` timeout=10      `|` run_on_failure=Nothing    | # Sets default timeout to 10 seconds and does nothing on failure           |
        """
        # pylint: disable=line-too-long
        self._block_until_page_ready = kwargs.pop('block_until_page_ready',
                                                  True)
        self._browser_breath_delay = float(
            kwargs.pop('browser_breath_delay', 0.05))
        self._builtin = BuiltIn()
        self._ensure_jq = kwargs.pop('ensure_jq', True)
        self._poll_frequency = float(kwargs.pop('poll_frequency', 0.2))
        Selenium2Library.__init__(self, implicit_wait=implicit_wait, **kwargs)
        ExtendedJavascriptKeywords.__init__(self)
        ExtendedWaitingKeywords.__init__(self)
        self._element_finder = ExtendedElementFinder()
        self._implicit_wait_in_secs = float(
            implicit_wait) if implicit_wait is not None else 15.0
        self._page_ready_keyword_list = []
        jquery_bootstrap = self.JQUERY_BOOTSTRAP % \
            {'jquery_url': self.JQUERY_URL} if self._ensure_jq else ''
        self._page_ready_bootstrap = self.PAGE_READY_WRAPPER % \
            {'jquery_bootstrap': jquery_bootstrap}
        self._table_element_finder._element_finder = self._element_finder  # pylint: disable=protected-access
Пример #2
0
 def __init__(self,
              timeout=5.0,
              implicit_wait=0.0,
              run_on_failure='Capture Page Screenshot',
              screenshot_root_directory=None):
     Selenium2Library.__init__(self, timeout, implicit_wait, run_on_failure,
                               screenshot_root_directory)
     self.tmpfiles = []
    def __init__(self, implicit_wait=15.0, **kwargs):
        # pylint: disable=line-too-long
        """ExtendedSelenium2Library can be imported with optional arguments.

        Arguments:
        - ``timeout``: The maximum value to wait for all waiting actions. (Default 5.0)
                       It can be set later with `Set Selenium Timeout`.
                       See `introduction` for more information about ``timeout``.
        - ``implicit_wait``: The maximum implicit timeout value to wait when looking
                             for elements. (Default 15.0)
                             It can be later set with `Set Selenium Implicit Wait`.
                             See [http://goo.gl/8ePMo6|WebDriver: Advanced Usage]
                             section of the SeleniumHQ documentation for more information about
                             WebDriver's implicit wait functionality.
        - ``run_on_failure``: The name of a keyword (from any available libraries) to execute
                              when a ExtendedSelenium2Library keyword fails. By default
                              `Capture Page Screenshot` will be used to take a screenshot of
                              the current page.
                              Using the value "Nothing" will disable this feature altogether.
                              See `Register Keyword To Run On Failure` keyword for
                              more information about this functionality.
        - ``screenshot_root_directory``: The default root directory that screenshots should be
                                         stored in. If not provided, the default directory will be
                                         where [http://goo.gl/lES6WM|Robot Framework] places its
                                         logfile.
        - ``block_until_page_ready``: A boolean flag to block the execution until
                                      the page is ready. (Default True)
        - ``browser_breath_delay``: The delay value in seconds to give the browser enough time to
                                    complete current execution. (Default 0.05)
        - ``ensure_jq``: A boolean flag to ensure jQuery library is loaded on the page.
                         ``sizzle`` locator strategy will depend on this flag. (Default True)
        - ``poll_frequency``: The delay value in seconds to retry the next step. (Default 0.2)

        Examples:
        | Library `|` ExtendedSelenium2Library `|` 15                                            | # Sets default timeout to 15 seconds                                       |
        | Library `|` ExtendedSelenium2Library `|` 0 `|` 5                                       | # Sets default timeout to 0 seconds and default implicit_wait to 5 seconds |
        | Library `|` ExtendedSelenium2Library `|` 5 `|` run_on_failure=Log Source               | # Sets default timeout to 5 seconds and runs `Log Source` on failure       |
        | Library `|` ExtendedSelenium2Library `|` implicit_wait=5 `|` run_on_failure=Log Source | # Sets default implicit_wait to 5 seconds and runs `Log Source` on failure |
        | Library `|` ExtendedSelenium2Library `|` timeout=10      `|` run_on_failure=Nothing    | # Sets default timeout to 10 seconds and does nothing on failure           |
        """
        # pylint: disable=line-too-long
        self._inputs = {
            'block_until_page_ready': bool(kwargs.pop('block_until_page_ready', True)),
            'browser_breath_delay': float(kwargs.pop('browser_breath_delay', 0.05)),
            'ensure_jq': bool(kwargs.pop('ensure_jq', True)),
            'poll_frequency': float(kwargs.pop('poll_frequency', 0.2)),
        }
        self._builtin = BuiltIn()
        Selenium2Library.__init__(self, implicit_wait=implicit_wait, **kwargs)
        ExtendedElementKeywords.__init__(self)
        ExtendedFormElementKeywords.__init__(self)
        ExtendedJavascriptKeywords.__init__(self)
        ExtendedSelectElementKeywords.__init__(self)
        ExtendedWaitingKeywords.__init__(self)
        self._implicit_wait_in_secs = float(implicit_wait) if implicit_wait is not None else 15.0
        self._page_ready_keyword_list = []
        # pylint: disable=protected-access
        self._table_element_finder._element_finder = self._element_finder
    def __init__(
        self,
        timeout=90.0,
        implicit_wait=15.0,
        run_on_failure="Capture Page Screenshot",
        block_until_page_ready=True,
        browser_breath_delay=0.05,
        ensure_jq=True,
        poll_frequency=0.2,
    ):
        # pylint: disable=line-too-long
        """ExtendedSelenium2Library can be imported with optional arguments.

        Arguments:
        - ``timeout``: The maximum value to wait for all waiting actions. (Default 90.0)
                       It can be set later with `Set Selenium Timeout`.
                       See `introduction` for more information about ``timeout``.
        - ``implicit_wait``: The maximum implicit timeout value to wait when looking
                             for elements. (Default 15.0)
                             It can be later set with `Set Selenium Implicit Wait`.
                             See [http://goo.gl/8ePMo6|WebDriver: Advanced Usage]
                             section of the SeleniumHQ documentation for more information about
                             WebDriver's implicit wait functionality.
        - ``run_on_failure``: The name of a keyword (from any available libraries) to execute
                              when a ExtendedSelenium2Library keyword fails. By default
                              `Capture Page Screenshot` will be used to take a screenshot of
                              the current page.
                              Using the value "Nothing" will disable this feature altogether.
                              See `Register Keyword To Run On Failure` keyword for
                              more information about this functionality.
        - ``block_until_page_ready``: A boolean flag to block the execution until
                                      the page is ready. (Default True)
        - ``browser_breath_delay``: The delay value in seconds to give the browser enough time to
                                    complete current execution. (Default 0.05)
        - ``ensure_jq``: A boolean flag to ensure jQuery library is loaded on the page.
                         ``sizzle`` locator strategy will depend on this flag. (Default True)
        - ``poll_frequency``: The delay value in seconds to retry the next step. (Default 0.2)

        Examples:
        | Library `|` ExtendedSelenium2Library `|` 15                                            | # Sets default timeout to 15 seconds                                       |
        | Library `|` ExtendedSelenium2Library `|` 0 `|` 5                                       | # Sets default timeout to 0 seconds and default implicit_wait to 5 seconds |
        | Library `|` ExtendedSelenium2Library `|` 5 `|` run_on_failure=Log Source               | # Sets default timeout to 5 seconds and runs `Log Source` on failure       |
        | Library `|` ExtendedSelenium2Library `|` implicit_wait=5 `|` run_on_failure=Log Source | # Sets default implicit_wait to 5 seconds and runs `Log Source` on failure |
        | Library `|` ExtendedSelenium2Library `|` timeout=10      `|` run_on_failure=Nothing    | # Sets default timeout to 10 seconds and does nothing on failure           |
        """
        # pylint: disable=line-too-long
        Selenium2Library.__init__(self, timeout, implicit_wait, run_on_failure)
        self._block_until_page_ready = block_until_page_ready
        self._browser_breath_delay = 0.05 if browser_breath_delay is None else float(browser_breath_delay)
        self._element_finder = ExtendedElementFinder()
        self._ensure_jq = True if ensure_jq else False
        self._implicit_wait_in_secs = 15.0 if implicit_wait is None else float(implicit_wait)
        jquery_bootstrap = self.JQUERY_BOOTSTRAP % {"jquery_url": self.JQUERY_URL} if self._ensure_jq else ""
        self._page_ready_bootstrap = self.PAGE_READY_WRAPPER % {"jquery_bootstrap": jquery_bootstrap}
        self._poll_frequency = 0.2 if poll_frequency is None else float(poll_frequency)
        self._table_element_finder._element_finder = self._element_finder  # pylint: disable=protected-access
        self._page_ready_keyword_list = []
        self._builtin = BuiltIn()
    def __init__(self, timeout=90.0, implicit_wait=15.0, run_on_failure='Capture Page Screenshot',
                 block_until_page_ready=True, browser_breath_delay=0.05, ensure_jq=True,
                 poll_frequency=0.2):
        # pylint: disable=line-too-long
        """ExtendedSelenium2Library can be imported with optional arguments.

        `timeout` is the default timeout used to wait for all waiting actions.
        It can be later set with `Set Selenium Timeout`.

        'implicit_wait' is the implicit timeout that Selenium waits when
        looking for elements.
        It can be later set with `Set Selenium Implicit Wait`.
        See `WebDriver: Advanced Usage`__ section of the SeleniumHQ documentation
        for more information about WebDriver's implicit wait functionality.

        __ http://seleniumhq.org/docs/04_webdriver_advanced.html#explicit-and-implicit-waits

        `run_on_failure` specifies the name of a keyword (from any available
        libraries) to execute when a ExtendedSelenium2Library keyword fails. By default
        `Capture Page Screenshot` will be used to take a screenshot of the current page.
        Using the value "Nothing" will disable this feature altogether. See
        `Register Keyword To Run On Failure` keyword for more information about this
        functionality.

        `block_until_page_ready` if it's true, will block the execution until the page ready.

        `browser_breath_delay` is the delay in seconds to give the browser enough time
        to execute the next step.

        `ensure_jq` if it's true, will ensure jQuery loaded on the page.

        `poll_frequency` is the number in seconds to retry the next step.

        Examples:
        | Library `|` ExtendedSelenium2Library `|` 15                                            | # Sets default timeout to 15 seconds                                       |
        | Library `|` ExtendedSelenium2Library `|` 0 `|` 5                                       | # Sets default timeout to 0 seconds and default implicit_wait to 5 seconds |
        | Library `|` ExtendedSelenium2Library `|` 5 `|` run_on_failure=Log Source               | # Sets default timeout to 5 seconds and runs `Log Source` on failure       |
        | Library `|` ExtendedSelenium2Library `|` implicit_wait=5 `|` run_on_failure=Log Source | # Sets default implicit_wait to 5 seconds and runs `Log Source` on failure |
        | Library `|` ExtendedSelenium2Library `|` timeout=10      `|` run_on_failure=Nothing    | # Sets default timeout to 10 seconds and does nothing on failure           |
        """
        # pylint: disable=line-too-long
        Selenium2Library.__init__(self, timeout, implicit_wait, run_on_failure)
        self._block_until_page_ready = block_until_page_ready
        self._browser_breath_delay = 0.05 \
            if browser_breath_delay is None else float(browser_breath_delay)
        self._ensure_jq = True if ensure_jq else False
        self._implicit_wait_in_secs = 15.0 \
            if implicit_wait is None else float(implicit_wait)
        jquery_bootstrap = self.JQUERY_BOOTSTRAP % \
            {'jquery_url': self.JQUERY_URL} if self._ensure_jq else ''
        self._page_ready_bootstrap = self.PAGE_READY_WRAPPER % \
            {'jquery_bootstrap': jquery_bootstrap}
        self._poll_frequency = 0.2 if poll_frequency is None else float(poll_frequency)
Пример #6
0
    def open_browser(self, url, browser="firefox", alias=None):
        #default to ff if we are not on windows
        if ((["ie", "internet explorer"].count(browser.lower()) > 0)
                and (self.get_os_name() != "win32")):
            browser = "firefox"  #there is not ie on mac or linux so set ie to firefox

        return Selenium2Library.open_browser(self, url, browser, alias)
Пример #7
0
def get_s2l():
    global s2l_handle
    if not s2l_handle:
        try:
            s2l_handle = BuiltIn().get_library_instance("Selenium2Library")
        except RuntimeError:
            s2l_handle = Selenium2Library()
    return s2l_handle
Пример #8
0
 def __init__(self, timeout=5.0, implicit_wait=0.0, run_on_failure="Capture Page Screenshot"):
     self.gps = XroadsGPS()
     self.alm = ALMUtil()  # lazy init the alm
     # TODO parameterize these connection information
     # self.xroads6_db = Xroads6DBUtil("xroads_app", "xroads", r'rhrac1scan.syniverse.com:1521/XRDSD1')
     self.button_xpath_candidates = (
         "xpath=//button[text()='%s']",
         "xpath=//input[@type='button' and @value='%s']",
         "xpath=//input[@type='submit' and @value='%s']",
         "xpath=//input[@type='reset' and @value='%s']",
         "xpath=//button[contains(text(),'%s')]",
         "xpath=//input[type='submit' and contains(@value,'%s')]",
         "xpath=//button[@id='%s']",
         "xpath=//input[@type='submit' and @id='%s']",
         "xpath=//input[@type='button' and @id='%s']",
     )
     Selenium2Library.__init__(self, timeout, implicit_wait, run_on_failure)
     logger.warn("XroadsPageDriver initialized")
Пример #9
0
    def __init__(self,
                 flash_app,
                 api_version=28,
                 sleep_after_call=0,
                 sleep_after_fail=0.1,
                 number_of_retries=30,
                 ensure_timeout=30,
                 selenium_timeout=5.0,
                 selenium_implicit_wait=0.0,
                 selenium_run_on_failure='',
                 selenium_screenshot_root_directory=None):
        """Initializes the library. Next use 'Open browser' keyword.

        Args:
            flash_app: the name for the flash application
            api_version: the version of SeleniumFlexAPI build into the application
            sleep_after_call: the wait after each executed command. Helpful for manually watching execution
            sleep_after_fail: wait time after each fail before trying again
            number_of_retries: number of times to retry the command
            ensure_timeout: how long to wait for ensure commands to succeed before giving up
            selenium_timeout: see Selenium2Library documentation
            selenium_implicit_wait: see Selenium2Library documentation
            selenium_run_on_failure: see Selenium2Library documentation
            selenium_screenshot_root_directory: see Selenium2Library documentation
        """
        Selenium2Library.__init__(self, selenium_timeout,
                                  selenium_implicit_wait,
                                  selenium_run_on_failure,
                                  selenium_screenshot_root_directory)

        FlexSeleniumKeywords.__init__(self, None, flash_app, int(api_version),
                                      float(sleep_after_call),
                                      float(sleep_after_fail),
                                      int(number_of_retries),
                                      float(ensure_timeout))
        FlexPilotKeywords.__init__(self, None, flash_app)
Пример #10
0
    def __init__(self,
                 flash_app, api_version=28, sleep_after_call=0, sleep_after_fail=0.1, number_of_retries=30,
                 ensure_timeout=30, selenium_timeout=5.0, selenium_implicit_wait=0.0, selenium_run_on_failure='',
                 selenium_screenshot_root_directory=None):
        """Initializes the library. Next use 'Open browser' keyword.

        Args:
            flash_app: the name for the flash application
            api_version: the version of SeleniumFlexAPI build into the application
            sleep_after_call: the wait after each executed command. Helpful for manually watching execution
            sleep_after_fail: wait time after each fail before trying again
            number_of_retries: number of times to retry the command
            ensure_timeout: how long to wait for ensure commands to succeed before giving up
            selenium_timeout: see Selenium2Library documentation
            selenium_implicit_wait: see Selenium2Library documentation
            selenium_run_on_failure: see Selenium2Library documentation
            selenium_screenshot_root_directory: see Selenium2Library documentation
        """
        Selenium2Library.__init__(self, selenium_timeout, selenium_implicit_wait, selenium_run_on_failure,
                                  selenium_screenshot_root_directory)

        FlexSeleniumKeywords.__init__(self, None, flash_app, int(api_version), float(sleep_after_call),
                                      float(sleep_after_fail), int(number_of_retries), float(ensure_timeout))
        FlexPilotKeywords.__init__(self, None, flash_app)
Пример #11
0
 def __init__(self):
     Selenium2Library.__init__(self)
     """Also this doc should be in shown in library doc."""
Пример #12
0
 def test_underscore_run_on_failure(self):
     when(RunOnFailureKeywords).run_on_failure().thenReturn(True)
     s2l = Selenium2Library()
     s2l._run_on_failure()
     verify(RunOnFailureKeywords, times=1).run_on_failure()
Пример #13
0
 def click_js(self, xpath):
     xpathElement = Selenium2Library.find_element(xpath)
     Selenium2Library._current_browser().execute_script(
         'return argument[0].click()', xpathElement)
Пример #14
0
 def open_browser(self, url, browser="firefox", alias=None):
     if (["ie", "internet explorer"].count(browser.lower()) > 0 ) and (self.get_os_name() == "darwin"):
         browser = "chrome"
     return Selenium2Library.open_browser(self, url, browser,alias)
Пример #15
0
    def __init__(self, timeout=0.0, client='Default', run_on_failure='Capture Page Screenshot'):
        super( EWSLibrary, self).__init__()

        Selenium2Library.__init__(self,timeout=timeout, run_on_failure=run_on_failure)
Пример #16
0
    def __init__(self,
                 timeout=0.0,
                 client=None,
                 run_on_failure='Capture Page Screenshot',
                 highlight=None,
                 log_console=None,
                 lang='en',
                 use_proxy=None,
                 test_data_dir=None,
                 login_data_dir=None,
                 or_dir=None):
        '''for the initi function timeout will be used to set both javascript timeout and
        the implicit_wait functunality.  Client is used to perform different functions for 
        different ews clients, say AZ vs Securex. run_on_failure is the robot framework keyword that 
        is run when a keyword fails, by default it is set to capturing a page screenshot, 
        test_data_dir holds path to TestData directory, login_data_dir holds path to login directory, 
        or_dir holds path to objectrepository directory'''
        super(EWSLibrary, self).__init__()

        #allow overwritting of EWSLibrary from command line
        timeout = self._cmdline_val("timeout", timeout)
        client = self._cmdline_val("client", client)
        highlight = self._cmdline_val("highlight", highlight)
        log_console = self._cmdline_val("log_console", log_console)
        lang = self._cmdline_val("lang", lang)
        use_proxy = self._cmdline_val("proxy", use_proxy)
        test_data_dir = self._cmdline_val("test_data_dir", test_data_dir)
        login_data_dir = self._cmdline_val("login_data_dir", login_data_dir)
        or_dir = self._cmdline_val("or_dir", or_dir)

        #setup an OR
        self.OR = ObjectRepository().default_OR

        #override global settings only if they were sepcifically passed in this
        #makes it easy to set global settings from run_tests.py
        new_settings = {}
        if client != None: new_settings["client"] = client
        if highlight != None: new_settings["highlight"] = highlight
        if log_console != None: new_settings["log_console"] = log_console
        if lang != 'en': new_settings['lang'] = lang
        if use_proxy is not None: new_settings['use_proxy'] = use_proxy
        if test_data_dir is not None:
            new_settings['test_data_dir'] = test_data_dir
        if login_data_dir is not None:
            new_settings['login_data_dir'] = login_data_dir
        if or_dir is not None: new_settings['or_dir'] = or_dir

        self.settings = Settings(new_settings)

        self.OR = self.settings.merge_ORs(self.OR)

        logger.console(
            "EWSLibrary created with timeout=%s , client=%s , "
            "highlight=%s , log_console=%s , run_on_failure=%s , lang=%s , test_data_dir=%s, "
            "login_data_dir=%s, or_dir=%s" %
            (timeout, client, highlight, log_console, run_on_failure, lang,
             test_data_dir, login_data_dir, or_dir))

        Selenium2Library.__init__(self,
                                  timeout=timeout,
                                  implicit_wait=timeout,
                                  run_on_failure=run_on_failure)
Пример #17
0
 def get_browser(self, RemoteUrl, Capabilities):
     robotDriverRemote = Selenium2Library.open_browser(
         "www.google.com",
         remote_url=RemoteUrl,
         desired_capabilities=Capabilities)
     return robotDriverRemote
Пример #18
0
    def __init__(self):
#         self.s2l=Selenium2Library()
        Selenium2Library.__init__(self)
Пример #19
0
 def __init__(self):
     Selenium2Library.__init__(self)
     self.driver = None
     self.xlsobj = do_xls()
Пример #20
0
 def __init__(self):
     Selenium2Library.__init__(self)
     AutoItLibrary.__init__(self)