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
Example #2
0
 def setUp(self):
     """Instantiate the extended form element class."""
     self.driver = mock.Mock()
     self.driver.session_id = 'session'
     self.element = ExtendedFormElementKeywords()
     # pylint: disable=protected-access
     self.element._info = mock.Mock()
     self.element._wait_until_page_ready = mock.Mock()
     self.group_name = 'group'
     self.locator = 'css=.selector'
     self.value = 'value'
     self.web_element = WebElement(self.driver, 'element', False)
     self.web_element.click = mock.Mock()
 def setUp(self):
     """Instantiate the extended form element class."""
     self.driver = mock.Mock()
     self.driver.session_id = 'session'
     self.element = ExtendedFormElementKeywords()
     # pylint: disable=protected-access
     self.element._info = mock.Mock()
     self.element._wait_until_page_ready = mock.Mock()
     self.group_name = 'group'
     self.locator = 'css=.selector'
     self.value = 'value'
     self.web_element = WebElement(self.driver, 'element', False)
     self.web_element.click = mock.Mock()
class ExtendedFormElementTests(unittest.TestCase):
    """Extended form element keyword test class."""

    def setUp(self):
        """Instantiate the extended form element class."""
        self.driver = mock.Mock()
        self.driver.session_id = 'session'
        self.element = ExtendedFormElementKeywords()
        # pylint: disable=protected-access
        self.element._info = mock.Mock()
        self.element._wait_until_page_ready = mock.Mock()
        self.group_name = 'group'
        self.locator = 'css=.selector'
        self.value = 'value'
        self.web_element = WebElement(self.driver, 'element', False)
        self.web_element.click = mock.Mock()

    def test_should_inherit_keywords(self):
        """Extended form element instance should inherit Selenium2 form element instances."""
        self.assertIsInstance(self.element, _FormElementKeywords)

    def test_should_click_input_button(self):
        """Should click an input button."""
        # pylint: disable=protected-access
        self.element._get_element_and_scroll_into_view_on_iexplore = mock.Mock()
        self.element._get_element_and_scroll_into_view_on_iexplore.return_value = self.web_element
        self.element.click_button(self.locator)
        self.element._info.assert_called_with("Clicking button '%s'." % self.locator)
        self.element._get_element_and_scroll_into_view_on_iexplore.\
            assert_called_with(self.locator, False, 'input')
        self.web_element.click.assert_called_with()
        self.element._wait_until_page_ready.assert_called_with()

    def test_should_click_input_button_and_skip_ready(self):
        """Should click an input button with skip_ready."""
        # pylint: disable=protected-access
        self.element._get_element_and_scroll_into_view_on_iexplore = mock.Mock()
        self.element._get_element_and_scroll_into_view_on_iexplore.return_value = self.web_element
        self.element.click_button(self.locator, True)
        self.element._info.assert_called_with("Clicking button '%s'." % self.locator)
        self.element._get_element_and_scroll_into_view_on_iexplore.\
            assert_called_with(self.locator, False, 'input')
        self.web_element.click.assert_called_with()
        self.assertFalse(self.element._wait_until_page_ready.called)

    def test_should_click_button(self):
        """Should click a button."""
        # pylint: disable=protected-access
        self.element._get_element_and_scroll_into_view_on_iexplore = mock.Mock()
        self.element._get_element_and_scroll_into_view_on_iexplore.\
            side_effect = [None, self.web_element]
        self.element.click_button(self.locator)
        self.element._info.assert_called_with("Clicking button '%s'." % self.locator)
        self.element._get_element_and_scroll_into_view_on_iexplore.\
            assert_called_with(self.locator, True, 'button')
        self.web_element.click.assert_called_with()
        self.element._wait_until_page_ready.assert_called_with()

    def test_should_click_button_and_skip_ready(self):
        """Should click a button with skip_ready."""
        # pylint: disable=protected-access
        self.element._get_element_and_scroll_into_view_on_iexplore = mock.Mock()
        self.element._get_element_and_scroll_into_view_on_iexplore.\
            side_effect = [None, self.web_element]
        self.element.click_button(self.locator, True)
        self.element._info.assert_called_with("Clicking button '%s'." % self.locator)
        self.element._get_element_and_scroll_into_view_on_iexplore.\
            assert_called_with(self.locator, True, 'button')
        self.web_element.click.assert_called_with()
        self.assertFalse(self.element._wait_until_page_ready.called)

    def test_should_select_checkbox(self):
        """Should select a checkbox."""
        # pylint: disable=protected-access
        self.element._get_checkbox = mock.Mock()
        self.element._get_checkbox.return_value = self.web_element
        self.element._select_checkbox_or_radio_button = mock.Mock()
        self.web_element.is_selected = mock.Mock()
        self.web_element.is_selected.return_value = False
        self.element.select_checkbox(self.locator)
        self.element._info.assert_called_with("Selecting checkbox '%s'." % self.locator)
        self.element._get_checkbox.assert_called_with(self.locator)
        self.web_element.is_selected.assert_called_with()
        self.element._select_checkbox_or_radio_button.assert_called_with(self.locator)

    def test_should_ignore_selected_checkbox(self):
        """Should ignore selected checkbox."""
        # pylint: disable=protected-access
        self.element._get_checkbox = mock.Mock()
        self.element._get_checkbox.return_value = self.web_element
        self.element._select_checkbox_or_radio_button = mock.Mock()
        self.web_element.is_selected = mock.Mock()
        self.web_element.is_selected.return_value = True
        self.element.select_checkbox(self.locator)
        self.element._info.assert_called_with("Selecting checkbox '%s'." % self.locator)
        self.element._get_checkbox.assert_called_with(self.locator)
        self.web_element.is_selected.assert_called_with()
        self.assertFalse(self.element._select_checkbox_or_radio_button.called)

    def test_should_select_radio_button(self):
        """Should select a radio button."""
        # pylint: disable=protected-access
        self.element._get_radio_button_with_value = mock.Mock()
        self.element._get_radio_button_with_value.return_value = self.web_element
        self.element._select_checkbox_or_radio_button = mock.Mock()
        self.web_element.is_selected = mock.Mock()
        self.web_element.is_selected.return_value = False
        self.element.select_radio_button(self.group_name, self.value)
        self.element._info.assert_called_with("Selecting '%s' from radio button '%s'." %
                                              (self.value, self.group_name))
        self.element._get_radio_button_with_value.assert_called_with(self.group_name, self.value)
        self.web_element.is_selected.assert_called_with()
        self.element._select_checkbox_or_radio_button.\
            assert_called_with('css=input[name="%s"][value="%s"]' % (self.group_name, self.value))

    def test_should_ignore_selected_radio_button(self):
        """Should ignore selected radio button."""
        # pylint: disable=protected-access
        self.element._get_radio_button_with_value = mock.Mock()
        self.element._get_radio_button_with_value.return_value = self.web_element
        self.element._select_checkbox_or_radio_button = mock.Mock()
        self.web_element.is_selected = mock.Mock()
        self.web_element.is_selected.return_value = True
        self.element.select_radio_button(self.group_name, self.value)
        self.element._info.assert_called_with("Selecting '%s' from radio button '%s'." %
                                              (self.value, self.group_name))
        self.element._get_radio_button_with_value.assert_called_with(self.group_name, self.value)
        self.web_element.is_selected.assert_called_with()
        self.assertFalse(self.element._select_checkbox_or_radio_button.called)

    def test_should_submit_form(self):
        """Should submit form."""
        # pylint: disable=protected-access
        self.element._get_element_and_scroll_into_view_on_iexplore = mock.Mock()
        self.element._get_element_and_scroll_into_view_on_iexplore.return_value = self.web_element
        self.web_element.submit = mock.Mock()
        self.element.submit_form(self.locator)
        self.element._info.assert_called_with("Submitting form '%s'." % self.locator)
        self.element._get_element_and_scroll_into_view_on_iexplore(self.locator, tag='form')
        self.web_element.submit.assert_called_with()
        self.element._wait_until_page_ready.assert_called_with()

    def test_should_submit_form_and_skip_ready(self):
        """Should submit form with skip_ready."""
        # pylint: disable=protected-access
        self.element._get_element_and_scroll_into_view_on_iexplore = mock.Mock()
        self.element._get_element_and_scroll_into_view_on_iexplore.return_value = self.web_element
        self.web_element.submit = mock.Mock()
        self.element.submit_form(self.locator, skip_ready=True)
        self.element._info.assert_called_with("Submitting form '%s'." % self.locator)
        self.element._get_element_and_scroll_into_view_on_iexplore(self.locator, tag='form')
        self.web_element.submit.assert_called_with()
        self.assertFalse(self.element._wait_until_page_ready.called)

    def test_should_submit_form_without_locator(self):
        """Should submit form without locator."""
        locator = 'xpath=//form'
        # pylint: disable=protected-access
        self.element._get_element_and_scroll_into_view_on_iexplore = mock.Mock()
        self.element._get_element_and_scroll_into_view_on_iexplore.return_value = self.web_element
        self.web_element.submit = mock.Mock()
        self.element.submit_form()
        self.element._info.assert_called_with("Submitting form '%s'." % locator)
        self.element._get_element_and_scroll_into_view_on_iexplore(locator, tag='form')
        self.web_element.submit.assert_called_with()
        self.element._wait_until_page_ready.assert_called_with()

    def test_should_submit_form_no_locator_and_skip_ready(self):
        """Should submit form without locator with skip_ready."""
        locator = 'xpath=//form'
        # pylint: disable=protected-access
        self.element._get_element_and_scroll_into_view_on_iexplore = mock.Mock()
        self.element._get_element_and_scroll_into_view_on_iexplore.return_value = self.web_element
        self.web_element.submit = mock.Mock()
        self.element.submit_form(skip_ready=True)
        self.element._info.assert_called_with("Submitting form '%s'." % locator)
        self.element._get_element_and_scroll_into_view_on_iexplore(locator, tag='form')
        self.web_element.submit.assert_called_with()
        self.assertFalse(self.element._wait_until_page_ready.called)

    def test_should_fill_text_field(self):
        """Should fill text field."""
        # pylint: disable=protected-access
        self.element._element_find = mock.Mock()
        self.element._element_find.return_value = self.web_element
        self.element._element_trigger_change = mock.Mock()
        self.web_element.clear = mock.Mock()
        self.web_element.send_keys = mock.Mock()
        self.element._input_text_into_text_field(self.locator, self.value)
        self.element._element_find(self.locator, True, True)
        self.web_element.clear.assert_called_with()
        self.web_element.send_keys.assert_called_with(self.value)
        self.element._element_trigger_change.assert_called_with(self.locator)

    def test_should_fill_text_field_and_skip_ready(self):
        """Should fill text field with skip_ready."""
        # pylint: disable=protected-access
        self.element._element_find = mock.Mock()
        self.element._element_find.return_value = self.web_element
        self.element._element_trigger_change = mock.Mock()
        self.web_element.clear = mock.Mock()
        self.web_element.send_keys = mock.Mock()
        self.element._input_text_into_text_field(self.locator, self.value, True)
        self.element._element_find(self.locator, True, True)
        self.web_element.clear.assert_called_with()
        self.web_element.send_keys.assert_called_with(self.value)
        self.assertFalse(self.element._element_trigger_change.called)

    def test_should_select_checkbox_or_radio_button(self):
        """Should select checkbox or radio button."""
        # pylint: disable=protected-access
        self.element._wait_until_page_ready = mock.Mock()
        self.element._select_checkbox_or_radio_button(self.locator)
        self.element._wait_until_page_ready.\
            assert_called_with(self.locator, skip_stale_check=True,
                               prefix='var cb=arguments[arguments.length-1];'
                                      'var el=arguments[0];if(window.angular){',
                               handler='function(){angular.element(el).'
                                       'prop(\'checked\',true).triggerHandler(\'click\');'
                                       'cb(true)}',
                               suffix='}else{el.click();cb(false)}')
Example #5
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._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
Example #6
0
class ExtendedFormElementTests(unittest.TestCase):
    """Extended form element keyword test class."""
    def setUp(self):
        """Instantiate the extended form element class."""
        self.driver = mock.Mock()
        self.driver.session_id = 'session'
        self.element = ExtendedFormElementKeywords()
        # pylint: disable=protected-access
        self.element._info = mock.Mock()
        self.element._wait_until_page_ready = mock.Mock()
        self.group_name = 'group'
        self.locator = 'css=.selector'
        self.value = 'value'
        self.web_element = WebElement(self.driver, 'element', False)
        self.web_element.click = mock.Mock()

    def test_should_inherit_keywords(self):
        """Extended form element instance should inherit Selenium2 form element instances."""
        self.assertIsInstance(self.element, FormElementKeywords)

    def test_should_click_input_button(self):
        """Should click an input button."""
        # pylint: disable=protected-access
        self.element._get_element_and_scroll_into_view_on_iexplore = mock.Mock(
        )
        self.element._get_element_and_scroll_into_view_on_iexplore.return_value = self.web_element
        self.element.click_button(self.locator)
        self.element._info.assert_called_with("Clicking button '%s'." %
                                              self.locator)
        self.element._get_element_and_scroll_into_view_on_iexplore.\
            assert_called_with(self.locator, False, 'input')
        self.web_element.click.assert_called_with()
        self.element._wait_until_page_ready.assert_called_with()

    def test_should_click_input_button_and_skip_ready(self):
        """Should click an input button with skip_ready."""
        # pylint: disable=protected-access
        self.element._get_element_and_scroll_into_view_on_iexplore = mock.Mock(
        )
        self.element._get_element_and_scroll_into_view_on_iexplore.return_value = self.web_element
        self.element.click_button(self.locator, True)
        self.element._info.assert_called_with("Clicking button '%s'." %
                                              self.locator)
        self.element._get_element_and_scroll_into_view_on_iexplore.\
            assert_called_with(self.locator, False, 'input')
        self.web_element.click.assert_called_with()
        self.assertFalse(self.element._wait_until_page_ready.called)

    def test_should_click_button(self):
        """Should click a button."""
        # pylint: disable=protected-access
        self.element._get_element_and_scroll_into_view_on_iexplore = mock.Mock(
        )
        self.element._get_element_and_scroll_into_view_on_iexplore.\
            side_effect = [None, self.web_element]
        self.element.click_button(self.locator)
        self.element._info.assert_called_with("Clicking button '%s'." %
                                              self.locator)
        self.element._get_element_and_scroll_into_view_on_iexplore.\
            assert_called_with(self.locator, True, 'button')
        self.web_element.click.assert_called_with()
        self.element._wait_until_page_ready.assert_called_with()

    def test_should_click_button_and_skip_ready(self):
        """Should click a button with skip_ready."""
        # pylint: disable=protected-access
        self.element._get_element_and_scroll_into_view_on_iexplore = mock.Mock(
        )
        self.element._get_element_and_scroll_into_view_on_iexplore.\
            side_effect = [None, self.web_element]
        self.element.click_button(self.locator, True)
        self.element._info.assert_called_with("Clicking button '%s'." %
                                              self.locator)
        self.element._get_element_and_scroll_into_view_on_iexplore.\
            assert_called_with(self.locator, True, 'button')
        self.web_element.click.assert_called_with()
        self.assertFalse(self.element._wait_until_page_ready.called)

    def test_should_select_checkbox(self):
        """Should select a checkbox."""
        # pylint: disable=protected-access
        self.element._get_checkbox = mock.Mock()
        self.element._get_checkbox.return_value = self.web_element
        self.element._select_checkbox_or_radio_button = mock.Mock()
        self.web_element.is_selected = mock.Mock()
        self.web_element.is_selected.return_value = False
        self.element.select_checkbox(self.locator)
        self.element._info.assert_called_with("Selecting checkbox '%s'." %
                                              self.locator)
        self.element._get_checkbox.assert_called_with(self.locator)
        self.web_element.is_selected.assert_called_with()
        self.element._select_checkbox_or_radio_button.assert_called_with(
            self.locator)

    def test_should_ignore_selected_checkbox(self):
        """Should ignore selected checkbox."""
        # pylint: disable=protected-access
        self.element._get_checkbox = mock.Mock()
        self.element._get_checkbox.return_value = self.web_element
        self.element._select_checkbox_or_radio_button = mock.Mock()
        self.web_element.is_selected = mock.Mock()
        self.web_element.is_selected.return_value = True
        self.element.select_checkbox(self.locator)
        self.element._info.assert_called_with("Selecting checkbox '%s'." %
                                              self.locator)
        self.element._get_checkbox.assert_called_with(self.locator)
        self.web_element.is_selected.assert_called_with()
        self.assertFalse(self.element._select_checkbox_or_radio_button.called)

    def test_should_select_radio_button(self):
        """Should select a radio button."""
        # pylint: disable=protected-access
        self.element._get_radio_button_with_value = mock.Mock()
        self.element._get_radio_button_with_value.return_value = self.web_element
        self.element._select_checkbox_or_radio_button = mock.Mock()
        self.web_element.is_selected = mock.Mock()
        self.web_element.is_selected.return_value = False
        self.element.select_radio_button(self.group_name, self.value)
        self.element._info.assert_called_with(
            "Selecting '%s' from radio button '%s'." %
            (self.value, self.group_name))
        self.element._get_radio_button_with_value.assert_called_with(
            self.group_name, self.value)
        self.web_element.is_selected.assert_called_with()
        self.element._select_checkbox_or_radio_button.\
            assert_called_with('css=input[name="%s"][value="%s"]' % (self.group_name, self.value))

    def test_should_ignore_selected_radio_button(self):
        """Should ignore selected radio button."""
        # pylint: disable=protected-access
        self.element._get_radio_button_with_value = mock.Mock()
        self.element._get_radio_button_with_value.return_value = self.web_element
        self.element._select_checkbox_or_radio_button = mock.Mock()
        self.web_element.is_selected = mock.Mock()
        self.web_element.is_selected.return_value = True
        self.element.select_radio_button(self.group_name, self.value)
        self.element._info.assert_called_with(
            "Selecting '%s' from radio button '%s'." %
            (self.value, self.group_name))
        self.element._get_radio_button_with_value.assert_called_with(
            self.group_name, self.value)
        self.web_element.is_selected.assert_called_with()
        self.assertFalse(self.element._select_checkbox_or_radio_button.called)

    def test_should_submit_form(self):
        """Should submit form."""
        # pylint: disable=protected-access
        self.element._get_element_and_scroll_into_view_on_iexplore = mock.Mock(
        )
        self.element._get_element_and_scroll_into_view_on_iexplore.return_value = self.web_element
        self.web_element.submit = mock.Mock()
        self.element.submit_form(self.locator)
        self.element._info.assert_called_with("Submitting form '%s'." %
                                              self.locator)
        self.element._get_element_and_scroll_into_view_on_iexplore(
            self.locator, tag='form')
        self.web_element.submit.assert_called_with()
        self.element._wait_until_page_ready.assert_called_with()

    def test_should_submit_form_and_skip_ready(self):
        """Should submit form with skip_ready."""
        # pylint: disable=protected-access
        self.element._get_element_and_scroll_into_view_on_iexplore = mock.Mock(
        )
        self.element._get_element_and_scroll_into_view_on_iexplore.return_value = self.web_element
        self.web_element.submit = mock.Mock()
        self.element.submit_form(self.locator, skip_ready=True)
        self.element._info.assert_called_with("Submitting form '%s'." %
                                              self.locator)
        self.element._get_element_and_scroll_into_view_on_iexplore(
            self.locator, tag='form')
        self.web_element.submit.assert_called_with()
        self.assertFalse(self.element._wait_until_page_ready.called)

    def test_should_submit_form_without_locator(self):
        """Should submit form without locator."""
        locator = 'xpath=//form'
        # pylint: disable=protected-access
        self.element._get_element_and_scroll_into_view_on_iexplore = mock.Mock(
        )
        self.element._get_element_and_scroll_into_view_on_iexplore.return_value = self.web_element
        self.web_element.submit = mock.Mock()
        self.element.submit_form()
        self.element._info.assert_called_with("Submitting form '%s'." %
                                              locator)
        self.element._get_element_and_scroll_into_view_on_iexplore(locator,
                                                                   tag='form')
        self.web_element.submit.assert_called_with()
        self.element._wait_until_page_ready.assert_called_with()

    def test_should_submit_form_no_locator_and_skip_ready(self):
        """Should submit form without locator with skip_ready."""
        locator = 'xpath=//form'
        # pylint: disable=protected-access
        self.element._get_element_and_scroll_into_view_on_iexplore = mock.Mock(
        )
        self.element._get_element_and_scroll_into_view_on_iexplore.return_value = self.web_element
        self.web_element.submit = mock.Mock()
        self.element.submit_form(skip_ready=True)
        self.element._info.assert_called_with("Submitting form '%s'." %
                                              locator)
        self.element._get_element_and_scroll_into_view_on_iexplore(locator,
                                                                   tag='form')
        self.web_element.submit.assert_called_with()
        self.assertFalse(self.element._wait_until_page_ready.called)

    def test_should_fill_text_field(self):
        """Should fill text field."""
        # pylint: disable=protected-access
        self.element._element_find = mock.Mock()
        self.element._element_find.return_value = self.web_element
        self.element._element_trigger_change = mock.Mock()
        self.web_element.clear = mock.Mock()
        self.web_element.send_keys = mock.Mock()
        self.element._input_text_into_text_field(self.locator, self.value)
        self.element._element_find(self.locator, True, True)
        self.web_element.clear.assert_called_with()
        self.web_element.send_keys.assert_called_with(self.value)
        self.element._element_trigger_change.assert_called_with(self.locator)

    def test_should_fill_text_field_and_skip_ready(self):
        """Should fill text field with skip_ready."""
        # pylint: disable=protected-access
        self.element._element_find = mock.Mock()
        self.element._element_find.return_value = self.web_element
        self.element._element_trigger_change = mock.Mock()
        self.web_element.clear = mock.Mock()
        self.web_element.send_keys = mock.Mock()
        self.element._input_text_into_text_field(self.locator, self.value,
                                                 True)
        self.element._element_find(self.locator, True, True)
        self.web_element.clear.assert_called_with()
        self.web_element.send_keys.assert_called_with(self.value)
        self.assertFalse(self.element._element_trigger_change.called)

    def test_should_select_checkbox_or_radio_button(self):
        """Should select checkbox or radio button."""
        # pylint: disable=protected-access
        self.element._wait_until_page_ready = mock.Mock()
        self.element._select_checkbox_or_radio_button(self.locator)
        self.element._wait_until_page_ready.\
            assert_called_with(self.locator, skip_stale_check=True,
                               prefix='var cb=arguments[arguments.length-1];'
                                      'var el=arguments[0];if(window.angular){',
                               handler='function(){angular.element(el).'
                                       'prop(\'checked\',true).triggerHandler(\'click\');'
                                       'cb(true)}',
                               suffix='}else{el.click();cb(false)}')