本文整理汇总了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)
示例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
#
示例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)
示例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()
示例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)
示例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)
示例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
示例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)