本文整理汇总了Python中selenium.webdriver.ActionChains.key_up方法的典型用法代码示例。如果您正苦于以下问题:Python ActionChains.key_up方法的具体用法?Python ActionChains.key_up怎么用?Python ActionChains.key_up使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.ActionChains
的用法示例。
在下文中一共展示了ActionChains.key_up方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: click_multiple_with_ctrl_down
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import key_up [as 别名]
def click_multiple_with_ctrl_down(self, locator,numbers=5):
elements = self._element_find(locator, False, True)
actions = ActionChains(self._current_browser())
actions.key_down(keys.Keys.CONTROL).perform()
sampl = random.sample(elements,int(numbers))
for e in sampl:
e.click()
actions.key_up(keys.Keys.CONTROL).perform()
示例2: test_report
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import key_up [as 别名]
def test_report(self):
self.browser.get(self.live_server_url + '/')
# Login
username = self.browser.find_element_by_id('username')
username.send_keys('Jim')
password = self.browser.find_element_by_id('password')
# Send the wrong password
password.send_keys('correcthorsebatterystaple')
# Submit the form
submit = self.browser.find_element_by_id('submit')
submit.click()
# Navigate to the sale page
img = self.browser.find_element_by_xpath(
'//div[@class="card small grey darken-3"][1]//img[@id="report-image"]')
img.click()
# Get the choose showing modal
showing = self.browser.find_element_by_xpath(
'//div[@class="col s6 center-align"][1]/button')
showing.click()
wait = WebDriverWait(self.browser, 10)
element = wait.until(EC.element_to_be_clickable((By.ID, 'picker-modal')))
modal = self.browser.find_element_by_id('picker-modal')
self.assertTrue(modal.is_displayed())
occ = self.browser.find_element_by_id('showing')
occ.click()
free_text = self.browser.find_element_by_xpath('//div[@id="sale-update"]//p').text
self.assertIn('No tickets sold', free_text)
self.assertIn('No tickets reserved', free_text)
self.assertIn('80 tickets left', free_text)
# Check selling tickets adds up properly
pricing = models.InHousePricing.objects.get(id=1)
member_price = pricing.member_price
concession_price = pricing.concession_price
public_price = pricing.public_price
mat_f_price = pricing.matinee_freshers_price
mat_f_nnt_price = pricing.matinee_freshers_nnt_price
out = self.browser.find_element_by_id('out1').text
member = self.browser.find_element_by_id('member')
action = ActionChains(self.browser)
action.click(on_element=member)
action.send_keys('1')
action.key_down(Keys.CONTROL)
action.key_up(Keys.CONTROL)
action.perform()
示例3: test_remove_success
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import key_up [as 别名]
def test_remove_success(self):
table = self.driver.find_element_by_id('dataTable')
self.create_units(table)
tr = table.find_element_by_css_selector('.htCore tbody tr:nth-child(' + str(3) + ')')
actions = ActionChains(self.driver)
actions.move_to_element(tr.find_element_by_css_selector('td:nth-child(2)'))
actions.click()
actions.key_down(Keys.SHIFT)
actions.move_to_element(table.find_element_by_css_selector('.htCore tbody tr:nth-child(' + str(5) + ') td:nth-child(3)'))
actions.click()
actions.key_up(Keys.SHIFT)
actions.move_to_element(table.find_element_by_css_selector('.htCore tbody tr:nth-child(' + str(4) + ') td:nth-child(3)'))
actions.context_click().send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN)
actions.send_keys(Keys.RETURN)
actions.perform()
self.assertEqual(len(self.driver.find_elements_by_css_selector('.htCore tbody tr')), 3 * 2)
示例4: test_remove_permission
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import key_up [as 别名]
def test_remove_permission(self):
table = self.driver.find_element_by_id('dataTable')
self.create_units(table)
self.driver.authorize(username=self.guest.email, password='qwerty')
self.driver.open_url(reverse('units:list', kwargs={'lab_pk': unicode(self.lab.pk)}))
table = self.driver.find_element_by_id('dataTable')
tr = table.find_element_by_css_selector('.htCore tbody tr:nth-child(1)')
actions = ActionChains(self.driver)
actions.move_to_element(tr.find_element_by_css_selector('td:nth-child(2)'))
actions.click()
actions.key_down(Keys.SHIFT)
actions.move_to_element(table.find_element_by_css_selector('.htCore tbody tr:nth-child(' + str(5) + ') td:nth-child(3)'))
actions.click()
actions.key_up(Keys.SHIFT)
actions.move_to_element(table.find_element_by_css_selector('.htCore tbody tr:nth-child(' + str(4) + ') td:nth-child(3)'))
actions.context_click().send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN)
actions.send_keys(Keys.RETURN)
actions.perform()
self.assertTrue(self.driver.is_element_present('.alert-danger'))
self.assertEqual(self.driver.find_element_by_css_selector('.messages').text, 'PERMISSION DENIED')
示例5: trigger_keystrokes
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import key_up [as 别名]
def trigger_keystrokes(browser, *keys):
""" Send the keys in sequence to the browser.
Handles following key combinations
1. with modifiers eg. 'control-alt-a', 'shift-c'
2. just modifiers eg. 'alt', 'esc'
3. non-modifiers eg. 'abc'
Modifiers : http://seleniumhq.github.io/selenium/docs/api/py/webdriver/selenium.webdriver.common.keys.html
"""
for each_key_combination in keys:
keys = each_key_combination.split('-')
if len(keys) > 1: # key has modifiers eg. control, alt, shift
modifiers_keys = [getattr(Keys, x.upper()) for x in keys[:-1]]
ac = ActionChains(browser)
for i in modifiers_keys: ac = ac.key_down(i)
ac.send_keys(keys[-1])
for i in modifiers_keys[::-1]: ac = ac.key_up(i)
ac.perform()
else: # single key stroke. Check if modifier eg. "up"
browser.send_keys(getattr(Keys, keys[0].upper(), keys[0]))