Python selenium.webdriver.common.keys.Keys 模块,BACK_SPACE 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用selenium.webdriver.common.keys.Keys.BACK_SPACE

项目:robotframework-weblibrary    作者:Netease-AutoTest    | 项目源码 | 文件源码
def _map_ascii_key_code_to_key(self, key_code):
        map = {
            0: Keys.NULL,
            8: Keys.BACK_SPACE,
            9: Keys.TAB,
            10: Keys.RETURN,
            13: Keys.ENTER,
            24: Keys.CANCEL,
            27: Keys.ESCAPE,
            32: Keys.SPACE,
            42: Keys.MULTIPLY,
            43: Keys.ADD,
            44: Keys.SEPARATOR,
            45: Keys.SUBTRACT,
            56: Keys.DECIMAL,
            57: Keys.DIVIDE,
            59: Keys.SEMICOLON,
            61: Keys.EQUALS,
            127: Keys.DELETE
        }
        key = map.get(key_code)
        if key is None:
            key = chr(key_code)
        return key
项目:reahl    作者:reahl    | 项目源码 | 文件源码
def press_backspace(self, locator):
        """Simulates the user pressing the backspace key while the element at `locator` has focus.

           :param locator: An instance of :class:`XPath` or a string containing an XPath expression.
        """
        self.find_element(locator).send_keys(Keys.BACK_SPACE)
项目:timestrap    作者:overshard    | 项目源码 | 文件源码
def clear(self, element):
        """Send back space commands to clear a form field element. This is used
        because Selenium's built-in clear() method is inconsistent."""
        value = element.get_attribute('value')
        if len(value) > 0:
            for char in value:
                element.send_keys(Keys.BACK_SPACE)
项目:PyWebRunner    作者:IntuitiveWebSolutions    | 项目源码 | 文件源码
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))
项目:Taurauto-Sharer    作者:sameerkumar18    | 项目源码 | 文件源码
def process(self,post_url, caption_text):
        groups = []
        #groups = ['https://www.facebook.com/groups/bangalorestartupsnetwork/',
        #          'https://www.facebook.com/groups/delhistartupnetwork/',
        #          'https://www.facebook.com/groups/indianstartupnetwork']
        time.sleep(1)
        if not groups:
            print "You might prefer to edit AutoShareFacebook.py?"
            try:
                number_of_groups = int(raw_input("Anyways How many groups:"))
                for j in range(0, number_of_groups):
                    app = raw_input("Enter group url(with https)" + str(j + 1) + ":")
                    groups.append(app)
                pass
            except:
                print "Error"

        else:
            pass

        for i in groups:
            try:
                self.driver.get(str(i))
                actions = ActionChains(self.driver)
                time.sleep(2)
                actions.send_keys('p').perform()
                time.sleep(1)

                actions2 = ActionChains(self.driver)
                actions2.send_keys(str(post_url) + " ").perform()
                time.sleep(3)


                actions4 = ActionChains(self.driver)

                for j in range(0, 15):
                    actions4.send_keys(Keys.BACK_SPACE).perform()

                caption = ActionChains(self.driver)
                caption.send_keys(caption_text).perform()

                click_post = self.driver.find_element_by_class_name("_332r")
                click_post.click()
                time.sleep(10)
                print "Successfully posted in " + str(i.split('https://www.facebook.com/groups/')[1].split('/')[0])
            except:
                print"Error posting in " + str(i.split('https://www.facebook.com/groups/')[1].split('/')[0])
        self.driver.close()
项目:Taurauto-Sharer    作者:sameerkumar18    | 项目源码 | 文件源码
def process(self,post_url, caption_text):
        groups = []
        #groups = ['https://www.facebook.com/groups/bangalorestartupsnetwork/',
        #          'https://www.facebook.com/groups/delhistartupnetwork/',
        #          'https://www.facebook.com/groups/indianstartupnetwork']
        time.sleep(1)
        if not groups:
            try:
                number_of_groups = int(raw_input("How many groups:"))
                for j in range(0, number_of_groups):
                    app = raw_input("Enter group url(with https)" + str(j + 1) + ":")
                    groups.append(app)
                pass
            except:
                print "Error"

        else:
            pass

        for i in groups:
            try:
                self.driver.get(str(i))
                actions = ActionChains(self.driver)
                time.sleep(2)
                actions.send_keys('p').perform()
                time.sleep(1)

                actions2 = ActionChains(self.driver)
                actions2.send_keys(str(post_url) + " ").perform()
                time.sleep(3)


                actions4 = ActionChains(self.driver)

                for j in range(0, 15):
                    actions4.send_keys(Keys.BACK_SPACE).perform()

                caption = ActionChains(self.driver)
                caption.send_keys(caption_text).perform()

                click_post = self.driver.find_element_by_class_name("_332r")
                click_post.click()
                time.sleep(10)
                print "Successfully posted in " + str(i.split('https://www.facebook.com/groups/')[1].split('/')[0])
            except:
                print"Error posting in " + str(i.split('https://www.facebook.com/groups/')[1].split('/')[0])
        self.driver.close()