Python selenium.webdriver.common.keys.Keys.BACK_SPACE Examples

The following are 17 code examples of selenium.webdriver.common.keys.Keys.BACK_SPACE(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module selenium.webdriver.common.keys.Keys , or try the search function .
Example #1
Source File: radiusbank.py    From finance-dl with GNU General Public License v2.0 6 votes vote down vote up
def login(self):
        if self.logged_in:
            return
        logger.info('Initiating log in')
        url = "https://banking.radiusbank.com/login"
        self.driver.get(url)

        (username, password), = self.wait_and_return(
            self.find_username_and_password_in_any_frame)
        logger.info('Entering username and password')
        # In case of autofill
        for i in range(50):
            username.send_keys(Keys.BACK_SPACE)
            password.send_keys(Keys.BACK_SPACE)
        username.send_keys(self.credentials['username'])
        password.send_keys(self.credentials['password'])
        with self.wait_for_page_load(timeout = 30):
            password.send_keys(Keys.ENTER)
        logger.info('Logged in')
        self.logged_in = True 
Example #2
Source File: usbank.py    From finance-dl with GNU General Public License v2.0 6 votes vote down vote up
def login(self):
        if self.logged_in:
            return
        logger.info('Initiating log in')
        url = "https://onlinebanking.usbank.com/Auth/Login"
        self.driver.get(url)

        (username, password), = self.wait_and_return(
            self.find_username_and_password_in_any_frame)
        logger.info('Entering username and password')
        # In case of autofill
        for i in range(50):
            username.send_keys(Keys.BACK_SPACE)
            password.send_keys(Keys.BACK_SPACE)
        username.send_keys(self.credentials['username'])
        password.send_keys(self.credentials['password'])
        with self.wait_for_page_load(timeout = 30):
            password.send_keys(Keys.ENTER)
        logger.info('Logged in')
        self.logged_in = True 
Example #3
Source File: test_selenium.py    From dokomoforms with GNU General Public License v3.0 6 votes vote down vote up
def test_integer_buckets_total_open(self):
        survey_id = self.survey_with_branch('integer', '(,)')

        self.get('/enumerate/{}'.format(survey_id))
        self.wait_for_element('navigate-right', By.CLASS_NAME)
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        (
            self.drv
            .find_element_by_tag_name('input')
            .send_keys('-999')
        )
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'b0'
        )
        self.click(self.drv.find_element_by_class_name('page_nav__prev'))
        self.input_field().send_keys(Keys.BACK_SPACE * 4, '999')
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'b0'
        ) 
Example #4
Source File: test_selenium.py    From dokomoforms with GNU General Public License v3.0 6 votes vote down vote up
def test_decimal_buckets_total_open(self):
        survey_id = self.survey_with_branch('decimal', '(,)')

        self.get('/enumerate/{}'.format(survey_id))
        self.wait_for_element('navigate-right', By.CLASS_NAME)
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        (
            self.drv
            .find_element_by_tag_name('input')
            .send_keys('-999.1')
        )
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'b0'
        )
        self.click(self.drv.find_element_by_class_name('page_nav__prev'))
        self.input_field().send_keys(Keys.BACK_SPACE * 6, '999.1')
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'b0'
        ) 
Example #5
Source File: Salesforce.py    From CumulusCI with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def populate_lookup_field(self, name, value):
        """Enters a value into a lookup field.
        """
        input_locator = self._get_input_field_locator(name)
        menu_locator = lex_locators["object"]["field_lookup_link"].format(value)

        self._populate_field(input_locator, value)

        for x in range(3):
            self.wait_for_aura()
            try:
                self.selenium.get_webelement(menu_locator)
            except ElementNotFound:
                # Give indexing a chance to catch up
                time.sleep(2)
                field = self.selenium.get_webelement(input_locator)
                field.send_keys(Keys.BACK_SPACE)
            else:
                break
        self.selenium.set_focus_to_element(menu_locator)
        self._jsclick(menu_locator) 
Example #6
Source File: test_selenium.py    From dokomoforms with GNU General Public License v3.0 5 votes vote down vote up
def test_date_buckets_open_ranges(self):
        survey_id = self.survey_with_branch(
            'date',
            '(, 2015-01-01)',
            '[2015-01-10,]'
        )

        self.get('/enumerate/{}'.format(survey_id))
        self.wait_for_element('navigate-right', By.CLASS_NAME)
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.enter_date(
            self.drv.find_element_by_tag_name('input'),
            '2014', '11', '22'
        )
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'b0'
        )
        self.click(self.drv.find_element_by_class_name('page_nav__prev'))
        self.input_field().send_keys(Keys.BACK_SPACE * 10)
        self.enter_date(
            self.drv.find_element_by_tag_name('input'),
            '2015', '11', '22'
        )
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'b1'
        )
        self.click(self.drv.find_element_by_class_name('page_nav__prev'))
        self.input_field().send_keys(Keys.BACK_SPACE * 10)
        self.enter_date(
            self.drv.find_element_by_tag_name('input'),
            '2015', '01', '05'
        )
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'last question'
        ) 
Example #7
Source File: __init__.py    From timestrap with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def clear(self, element):
        # Selenium's clear command doesn't work
        value = element.get_attribute("value")
        for character in value:
            element.send_keys(Keys.BACK_SPACE) 
Example #8
Source File: course-updates.py    From ANALYSE with GNU Affero General Public License v3.0 5 votes vote down vote up
def change_date(_step, new_date):
    button_css = 'div.post-preview a.edit-button'
    world.css_click(button_css)
    date_css = 'input.date'
    date = world.css_find(date_css)
    for i in range(len(date.value)):
        date._element.send_keys(Keys.END, Keys.BACK_SPACE)
    date._element.send_keys(new_date)
    save_css = 'a.save-button'
    world.css_click(save_css) 
Example #9
Source File: test_selenium.py    From dokomoforms with GNU General Public License v3.0 5 votes vote down vote up
def test_timestamp_buckets_total_open(self):
        survey_id = self.survey_with_branch('timestamp', '(,)')

        self.get('/enumerate/{}'.format(survey_id))
        self.wait_for_element('navigate-right', By.CLASS_NAME)
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.enter_timestamp(
            self.drv.find_element_by_tag_name('input'),
            '1970-01-05T01:00:00'
        )
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'b0'
        )
        self.click(self.drv.find_element_by_class_name('page_nav__prev'))
        self.input_field().send_keys(Keys.RIGHT * 30, Keys.BACK_SPACE * 30)
        self.enter_timestamp(
            self.drv.find_element_by_tag_name('input'),
            '2070-01-05T01:00:00'
        )
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'b0'
        ) 
Example #10
Source File: test_selenium.py    From dokomoforms with GNU General Public License v3.0 5 votes vote down vote up
def test_timestamp_buckets(self):
        survey_id = self.survey_with_branch(
            'timestamp',
            '(2015-01-01T12:00:00Z, 2015-01-03T12:00:00Z)',
            '[2015-01-04T12:00:00Z, 2015-01-05T12:00:00Z]'
        )

        self.get('/enumerate/{}'.format(survey_id))
        self.wait_for_element('navigate-right', By.CLASS_NAME)
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.enter_timestamp(
            self.drv.find_element_by_tag_name('input'),
            '2015-01-02T12:00:00'
        )
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'b0'
        )
        self.click(self.drv.find_element_by_class_name('page_nav__prev'))
        self.input_field().send_keys(Keys.RIGHT * 30, Keys.BACK_SPACE * 30)
        self.enter_timestamp(
            self.drv.find_element_by_tag_name('input'),
            '2015-01-04T12:00:00'
        )
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'b1'
        )
        self.click(self.drv.find_element_by_class_name('page_nav__prev'))
        self.input_field().send_keys(Keys.RIGHT * 30, Keys.BACK_SPACE * 30)
        self.enter_timestamp(
            self.drv.find_element_by_tag_name('input'),
            '2015-01-01T12:00:00'
        )
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'last question'
        ) 
Example #11
Source File: test_selenium.py    From dokomoforms with GNU General Public License v3.0 5 votes vote down vote up
def test_date_buckets_total_open(self):
        survey_id = self.survey_with_branch('date', '(,)')

        self.get('/enumerate/{}'.format(survey_id))
        self.wait_for_element('navigate-right', By.CLASS_NAME)
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.enter_date(
            self.drv.find_element_by_tag_name('input'),
            '1970', '01', '05'
        )
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'b0'
        )
        self.click(self.drv.find_element_by_class_name('page_nav__prev'))
        self.input_field().send_keys(Keys.BACK_SPACE * 10)
        self.enter_date(
            self.drv.find_element_by_tag_name('input'),
            '2070', '01', '05'
        )
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'b0'
        ) 
Example #12
Source File: test_selenium.py    From dokomoforms with GNU General Public License v3.0 5 votes vote down vote up
def test_date_buckets(self):
        survey_id = self.survey_with_branch(
            'date',
            '(2015-01-01, 2015-01-03)',
            '[2015-01-04, 2015-01-05]'
        )

        self.get('/enumerate/{}'.format(survey_id))
        self.wait_for_element('navigate-right', By.CLASS_NAME)
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.enter_date(
            self.drv.find_element_by_tag_name('input'),
            '2015', '01', '02'
        )
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'b0'
        )
        self.click(self.drv.find_element_by_class_name('page_nav__prev'))
        self.input_field().send_keys(Keys.BACK_SPACE * 10)
        self.enter_date(
            self.drv.find_element_by_tag_name('input'),
            '2015', '01', '04'
        )
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'b1'
        )
        self.click(self.drv.find_element_by_class_name('page_nav__prev'))
        self.input_field().send_keys(Keys.BACK_SPACE * 10)
        self.enter_date(
            self.drv.find_element_by_tag_name('input'),
            '2015', '01', '01'
        )
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'last question'
        ) 
Example #13
Source File: test_selenium.py    From dokomoforms with GNU General Public License v3.0 5 votes vote down vote up
def test_decimal_buckets(self):
        survey_id = self.survey_with_branch(
            'decimal',
            '(1.2, 3.2)',
            '[4.2, 5.2]'
        )

        self.get('/enumerate/{}'.format(survey_id))
        self.wait_for_element('navigate-right', By.CLASS_NAME)
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        (
            self.drv
            .find_element_by_tag_name('input')
            .send_keys('1.3')
        )
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'b0'
        )
        self.click(self.drv.find_element_by_class_name('page_nav__prev'))
        self.input_field().send_keys(Keys.BACK_SPACE * 3, '4.2')
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'b1'
        )
        self.click(self.drv.find_element_by_class_name('page_nav__prev'))
        self.input_field().send_keys(Keys.BACK_SPACE * 3, '1.2')
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'last question'
        ) 
Example #14
Source File: test_selenium.py    From dokomoforms with GNU General Public License v3.0 5 votes vote down vote up
def test_integer_buckets_open_ranges(self):
        survey_id = self.survey_with_branch('integer', '(, 0)', '[10,)')

        self.get('/enumerate/{}'.format(survey_id))
        self.wait_for_element('navigate-right', By.CLASS_NAME)
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        (
            self.drv
            .find_element_by_tag_name('input')
            .send_keys('-5')
        )
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'b0'
        )
        self.click(self.drv.find_element_by_class_name('page_nav__prev'))
        self.input_field().send_keys(Keys.BACK_SPACE * 2, '15')
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'b1'
        )
        self.click(self.drv.find_element_by_class_name('page_nav__prev'))
        self.input_field().send_keys(Keys.BACK_SPACE * 2, '5')
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'last question'
        ) 
Example #15
Source File: test_selenium.py    From dokomoforms with GNU General Public License v3.0 5 votes vote down vote up
def test_integer_buckets(self):
        survey_id = self.survey_with_branch('integer', '(1, 3)', '[4, 5]')

        self.get('/enumerate/{}'.format(survey_id))
        self.wait_for_element('navigate-right', By.CLASS_NAME)
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        (
            self.drv
            .find_element_by_tag_name('input')
            .send_keys('2')
        )
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'b0'
        )
        self.click(self.drv.find_element_by_class_name('page_nav__prev'))
        self.input_field().send_keys(Keys.BACK_SPACE, '4')
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'b1'
        )
        self.click(self.drv.find_element_by_class_name('page_nav__prev'))
        self.input_field().send_keys(Keys.BACK_SPACE, '1')
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.assertEqual(
            self.drv.find_element_by_tag_name('h3').text,
            'last question'
        ) 
Example #16
Source File: WebRunner.py    From PyWebRunner with MIT License 4 votes vote down vote up
def set_selectize(self, selector, value, text=None, clear=True, blur=False):
        '''
        Sets visible value of a selectize control based on the "selectized" element.

        Parameters
        ----------
        selector: str
            A CSS selector to search for. This can be any valid CSS selector.

        value: str
            The value of the option to select.
            (Stored Value)

        text: str
            The visible value that the user sees.
            (Visible value, if different than the stored value)

        clear: bool
            Whether or not we should clear the selectize value first.
            Defaults to True

        blur: bool
            Whether or not we should blur the element after setting the value.
            This corresponds to the 'selectOnTab' selecize setting.
            Defaults to False
        '''
        selectize_control = selector + ' + .selectize-control'
        selectize_input = selectize_control + ' input'

        # Make sure the selectize control is active so the input is visible
        self.click(selectize_control)

        input_element = self.get_element(selectize_input)

        if clear:
            input_element.send_keys(Keys.BACK_SPACE)

        input_element.send_keys(text or value)

        # Wait for options to be rendered
        self.wait_for_visible(selectize_control + ' .has-options')

        if blur:
            input_element.send_keys(Keys.TAB)
        else:
            # Click the option for the given value
            self.click(selectize_control + ' .option[data-value="{}"]'.format(value)) 
Example #17
Source File: test_selenium.py    From dokomoforms with GNU General Public License v3.0 4 votes vote down vote up
def test_required_question_bad_answer(self):
        user = (
            self.session
            .query(Administrator)
            .get('b7becd02-1a3f-4c1d-a0e1-286ba121aef4')
        )
        node = (
            self.session
            .query(Node)
            .filter(Node.title['English'].astext == 'integer_node')
            .one()
        )
        with self.session.begin():
            survey = construct_survey(
                creator=user,
                survey_type='public',
                title={'English': 'required question'},
                nodes=[
                    construct_survey_node(
                        required=True,
                        node=node,
                    ),
                ],
            )
            self.session.add(survey)

        survey_id = survey.id

        self.get('/enumerate/{}'.format(survey_id))
        self.wait_for_element('navigate-right', By.CLASS_NAME)
        self.click(self.drv.find_element_by_class_name('navigate-right'))

        (
            self.drv
            .find_element_by_tag_name('input')
            .send_keys('not an integer')
        )
        self.click(self.drv.find_element_by_class_name('navigate-right'))

        # An alert pops up
        # TODO: change this behavior
        alert = self.drv.switch_to.alert
        alert.accept()

        self.input_field().send_keys(
            Keys.RIGHT * 14, Keys.BACK_SPACE * 14, '3'
        )

        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.click(self.drv.find_element_by_class_name('navigate-right'))
        self.click(self.drv.find_elements_by_tag_name('button')[0])

        new_submission = self.get_last_submission(survey_id)

        self.assertEqual(new_submission.answers[0].answer, 3)