當前位置: 首頁>>代碼示例>>Python>>正文


Python Keys.DELETE屬性代碼示例

本文整理匯總了Python中selenium.webdriver.common.keys.Keys.DELETE屬性的典型用法代碼示例。如果您正苦於以下問題:Python Keys.DELETE屬性的具體用法?Python Keys.DELETE怎麽用?Python Keys.DELETE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在selenium.webdriver.common.keys.Keys的用法示例。


在下文中一共展示了Keys.DELETE屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: set_position

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import DELETE [as 別名]
def set_position(driver, settings: str):
    browser = browser_(driver)

    # TODO figure out browser from driver??
    field = driver.find_element_by_xpath('//*[@id="position_css_id"]')
    if browser.name == 'chrome':
        # ugh... for some reason wouldn't send the keys...
        field.click()
        import pyautogui # type: ignore
        # it usually ends up in the middle of the area...
        pyautogui.press(['backspace'] * 500 + ['delete'] * 500)
        pyautogui.typewrite(settings, interval=0.05)
    else:
        area = field.find_element_by_xpath('.//textarea')
        area.send_keys([Keys.DELETE] * 1000)
        area.send_keys(settings) 
開發者ID:karlicoss,項目名稱:promnesia,代碼行數:18,代碼來源:end2end_test.py

示例2: edit_cell

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import DELETE [as 別名]
def edit_cell(self, cell=None, index=0, content="", render=False):
        """Set the contents of a cell to *content*, by cell object or by index
        """
        if cell is not None:
            index = self.index(cell)

        # # Select & delete anything already in the cell
        # self.current_cell.send_keys(Keys.ENTER)

        # if platform == "darwin":
        #     command(self.browser, 'a')
        # else:
        #     ctrl(self.browser, 'a')

        # self.current_cell.send_keys(Keys.DELETE)
        self.browser.execute_script("IPython.notebook.get_cell(" + str(index) +
                                    ").set_text(" + repr(dedent(content)) + ")")
        self._focus_cell(index)

        if render:
            self.execute_cell(self.current_index)

    #
    # Get info
    # 
開發者ID:vatlab,項目名稱:sos-notebook,代碼行數:27,代碼來源:test_utils.py

示例3: delete

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import DELETE [as 別名]
def delete(self):
        elem = self.__get_element(self.k, self.v)
        elem.send_keys(Keys.DELETE) 
開發者ID:SeldomQA,項目名稱:poium,代碼行數:5,代碼來源:page_objects.py

示例4: send_keys

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import DELETE [as 別名]
def send_keys(self, element, arg):
        """
        [Internal]

        Clicks two times on the Selenium element.

        :param element: Selenium element
        :type element: Selenium object
        :param arg: Text or Keys to be sent to the element
        :type arg: str or selenium.webdriver.common.keys

        Usage:

        >>> #Defining the element:
        >>> element = lambda: self.driver.find_element_by_id("example_id")
        >>> #Calling the method with a string
        >>> self.send_keys(element(), "Text")
        >>> #Calling the method with a Key
        >>> self.send_keys(element(), Keys.ENTER)
        """
        try:
            if arg.isprintable():
                element.clear()
                element.send_keys(Keys.CONTROL, 'a')
            element.send_keys(arg)
        except Exception:
            actions = ActionChains(self.driver)
            actions.move_to_element(element)
            actions.click()
            if arg.isprintable():
                actions.key_down(Keys.CONTROL).send_keys('a').key_up(Keys.CONTROL).send_keys(Keys.DELETE)
            actions.send_keys(Keys.HOME)
            actions.send_keys(arg)
            actions.perform() 
開發者ID:totvs,項目名稱:tir,代碼行數:36,代碼來源:base.py

示例5: clear

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import DELETE [as 別名]
def clear(element):
    element.clear()
    element.send_keys(SELECT_ALL)
    element.send_keys(Keys.DELETE)
    time.sleep(DELAY_BREAK_MINI * 0.5) 
開發者ID:timelyart,項目名稱:Kairos,代碼行數:7,代碼來源:tv.py

示例6: delete

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import DELETE [as 別名]
def delete(self):
            self.elem.send_keys(Keys.DELETE) 
開發者ID:SeldomQA,項目名稱:seldom,代碼行數:4,代碼來源:webdriver.py

示例7: morningMessage

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import DELETE [as 別名]
def morningMessage():
    #Sending message
    global driver
    global bae
    msg = random.choice(config.custom_morning_messages)
    baestr = str('"' + bae + '"')

    #Some Selenium stuff, don't bother
    try:
        pyperclip.copy(bae)
        searchbar = driver.find_elements_by_xpath('//*[@id="side"]/div[1]/div/label/input')[0]
        searchbar.click() #Click on searchbar
        searchbar.send_keys(Keys.CONTROL, 'v') #Search for contact for more speed
        x_arg = '//span[contains(@title,' + baestr + ')]'
        group_title = wait.until(EC.presence_of_element_located((By.XPATH, x_arg)))
        group_title.click()
        time.sleep(0.1)
        pyperclip.copy(msg) #Copies random message to clipboard
        message = driver.find_elements_by_xpath('//*[@id="main"]/footer/div[1]/div[2]/div/div[2]')[0]
        message.send_keys(Keys.CONTROL, 'v') #Sends message from clipboard
        time.sleep(0.1)
        sendbutton = driver.find_elements_by_xpath('//*[@id="main"]/footer/div[1]/div[3]/button')[0]
        sendbutton.click() #Presses send button
        searchbar.click() #Click on searchbar
        searchbar.send_keys(Keys.CONTROL, 'a') #Select all
        searchbar.send_keys(Keys.DELETE) #Delete searchbar content
        print("Message {} successfully sent to {}" .format(msg, bae))
    except:
        print("Problem sending, retrying...")
        morningMessage()
        pass
    return

#Getting username & pwd 
開發者ID:lorcalhost,項目名稱:RomanceBreaker,代碼行數:36,代碼來源:whatsappRB.py

示例8: test_remove_url_slug

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import DELETE [as 別名]
def test_remove_url_slug(self):
        user = (
            self.session
            .query(Administrator)
            .get('b7becd02-1a3f-4c1d-a0e1-286ba121aef4')
        )
        with self.session.begin():
            survey = construct_survey(
                creator=user,
                survey_type='public',
                title={'English': 'slug playground'},
            )
            self.session.add(survey)

        survey_id = survey.id

        self.get('/admin/' + survey_id)

        edit_btn = self.drv.find_element_by_class_name('glyphicon-pencil')
        self.click(edit_btn)

        slug_field = self.drv.find_element_by_class_name('shareable-url-slug')
        slug_field.send_keys('slug')
        self.click(self.drv.find_element_by_class_name('save-survey-url'))

        new_link = self.drv.find_element_by_id('shareable-link').text
        self.assertEqual(new_link, 'http://localhost:9999/enumerate/slug')

        edit_btn = self.drv.find_element_by_class_name('glyphicon-pencil')
        self.click(edit_btn)
        slug_field = self.drv.find_element_by_class_name('shareable-url-slug')
        slug_field.send_keys(Keys.DELETE)
        self.click(self.drv.find_element_by_class_name('save-survey-url'))

        new_old_link = self.drv.find_element_by_id('shareable-link').text
        self.assertEqual(
            new_old_link,
            'http://localhost:9999/enumerate/' + survey_id
        )

        self.get('/enumerate/slug')
        self.assertIn('404', self.drv.page_source) 
開發者ID:SEL-Columbia,項目名稱:dokomoforms,代碼行數:44,代碼來源:test_selenium.py


注:本文中的selenium.webdriver.common.keys.Keys.DELETE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。