本文整理汇总了Python中selenium.webdriver.common.keys.Keys.ARROW_DOWN属性的典型用法代码示例。如果您正苦于以下问题:Python Keys.ARROW_DOWN属性的具体用法?Python Keys.ARROW_DOWN怎么用?Python Keys.ARROW_DOWN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类selenium.webdriver.common.keys.Keys
的用法示例。
在下文中一共展示了Keys.ARROW_DOWN属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clear_chat
# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import ARROW_DOWN [as 别名]
def clear_chat(self, name):
self.browser.find_element_by_css_selector("._3FRCZ").send_keys(name+Keys.ENTER)
menu_xpath = "/html/body/div[1]/div/div/div[4]/div/header/div[3]/div/div[3]/div/span"
WebDriverWait(self.browser, self.timeout).until(EC.presence_of_element_located(
(By.XPATH, menu_xpath)))
menu = self.browser.find_element_by_xpath(menu_xpath)
menu.click()
chains = ActionChains(self.browser)
for i in range(4):
chains.send_keys(Keys.ARROW_DOWN)
chains.send_keys(Keys.ENTER)
chains.perform()
clear_xpath = '//*[@id="app"]/div/span[2]/div/div/div/div/div/div/div[2]/div[2]'
WebDriverWait(self.browser, self.timeout).until(EC.presence_of_element_located(
(By.XPATH, clear_xpath)))
self.browser.find_element_by_xpath(clear_xpath).click()
# override the timeout
示例2: get_starred_messages
# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import ARROW_DOWN [as 别名]
def get_starred_messages(self, delay=10):
starred_messages = []
self.browser.find_element_by_css_selector("div.rAUz7:nth-child(3) > div:nth-child(1) > span:nth-child(1)").click()
chains = ActionChains(self.browser)
time.sleep(2)
for i in range(4):
chains.send_keys(Keys.ARROW_DOWN)
chains.send_keys(Keys.ENTER)
chains.perform()
time.sleep(delay)
messages = self.browser.find_elements_by_class_name("MS-DH")
for message in messages:
try:
message_html = message.get_attribute("innerHTML")
soup = BeautifulSoup(message_html, "html.parser")
_from = soup.find("span", class_="_1qUQi")["title"]
to = soup.find("div", class_="copyable-text")["data-pre-plain-text"]
message_text = soup.find("span", class_="selectable-text invisible-space copyable-text").text
message.click()
selector = self.browser.find_element_by_css_selector("#main > header > div._5SiUq > div._16vzP > div > span")
title = selector.text
selector.click()
time.sleep(2)
WebDriverWait(self.browser, 5).until(EC.presence_of_element_located((By.CSS_SELECTOR, "div._14oqx:nth-child(3) > div:nth-child(1) > div:nth-child(1) > span:nth-child(1) > span:nth-child(1)")))
phone = self.browser.find_element_by_css_selector("div._14oqx:nth-child(3) > div:nth-child(1) > div:nth-child(1) > span:nth-child(1) > span:nth-child(1)").text
if title in _from:
_from = _from.replace(title, phone)
else:
to = to.replace(title, phone)
starred_messages.append([_from, to, message_text])
except Exception as e:
print("Handled: ", e)
return starred_messages
# Getting usernames which has unread messages
示例3: create_group
# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import ARROW_DOWN [as 别名]
def create_group(self, group_name, members):
more = self.browser.find_element_by_css_selector("#side > header > div._20NlL > div > span > div:nth-child(3) > div > span")
more.click()
chains = ActionChains(self.browser)
chains.send_keys(Keys.ARROW_DOWN+Keys.ENTER)
chains.perform()
for member in members:
contact_name = self.browser.find_element_by_css_selector("._16RnB")
contact_name.send_keys(member+Keys.ENTER)
time.sleep(3) # little delay to make the process robust
next_step = self.browser.find_element_by_css_selector("._3hV1n > span:nth-child(1)")
next_step.click()
group_text = self.browser.find_element_by_css_selector(".bsmJe > div:nth-child(2)")
group_text.send_keys(group_name+Keys.ENTER)
示例4: bowhead
# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import ARROW_DOWN [as 别名]
def bowhead(self):
self.driver.find_element_by_tag_name("body").send_keys(Keys.ARROW_DOWN)
示例5: test_select
# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import ARROW_DOWN [as 别名]
def test_select(self):
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
self.selenium.get(self.live_server_url + reverse('autocomplete_admin:admin_views_answer_add'))
elem = self.selenium.find_element_by_css_selector('.select2-selection')
elem.click() # Open the autocomplete dropdown.
results = self.selenium.find_element_by_css_selector('.select2-results')
self.assertTrue(results.is_displayed())
option = self.selenium.find_element_by_css_selector('.select2-results__option')
self.assertEqual(option.text, 'No results found')
elem.click() # Close the autocomplete dropdown.
q1 = Question.objects.create(question='Who am I?')
Question.objects.bulk_create(Question(question=str(i)) for i in range(PAGINATOR_SIZE + 10))
elem.click() # Reopen the dropdown now that some objects exist.
result_container = self.selenium.find_element_by_css_selector('.select2-results')
self.assertTrue(result_container.is_displayed())
results = result_container.find_elements_by_css_selector('.select2-results__option')
# PAGINATOR_SIZE results and "Loading more results".
self.assertEqual(len(results), PAGINATOR_SIZE + 1)
search = self.selenium.find_element_by_css_selector('.select2-search__field')
# Load next page of results by scrolling to the bottom of the list.
for _ in range(len(results)):
search.send_keys(Keys.ARROW_DOWN)
results = result_container.find_elements_by_css_selector('.select2-results__option')
# All objects and "Loading more results".
self.assertEqual(len(results), PAGINATOR_SIZE + 11)
# Limit the results with the search field.
search.send_keys('Who')
results = result_container.find_elements_by_css_selector('.select2-results__option')
self.assertEqual(len(results), 1)
# Select the result.
search.send_keys(Keys.RETURN)
select = Select(self.selenium.find_element_by_id('id_question'))
self.assertEqual(select.first_selected_option.get_attribute('value'), str(q1.pk))
示例6: test_select_multiple
# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import ARROW_DOWN [as 别名]
def test_select_multiple(self):
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
self.selenium.get(self.live_server_url + reverse('autocomplete_admin:admin_views_question_add'))
elem = self.selenium.find_element_by_css_selector('.select2-selection')
elem.click() # Open the autocomplete dropdown.
results = self.selenium.find_element_by_css_selector('.select2-results')
self.assertTrue(results.is_displayed())
option = self.selenium.find_element_by_css_selector('.select2-results__option')
self.assertEqual(option.text, 'No results found')
elem.click() # Close the autocomplete dropdown.
Question.objects.create(question='Who am I?')
Question.objects.bulk_create(Question(question=str(i)) for i in range(PAGINATOR_SIZE + 10))
elem.click() # Reopen the dropdown now that some objects exist.
result_container = self.selenium.find_element_by_css_selector('.select2-results')
self.assertTrue(result_container.is_displayed())
results = result_container.find_elements_by_css_selector('.select2-results__option')
self.assertEqual(len(results), PAGINATOR_SIZE + 1)
search = self.selenium.find_element_by_css_selector('.select2-search__field')
# Load next page of results by scrolling to the bottom of the list.
for _ in range(len(results)):
search.send_keys(Keys.ARROW_DOWN)
results = result_container.find_elements_by_css_selector('.select2-results__option')
self.assertEqual(len(results), 31)
# Limit the results with the search field.
search.send_keys('Who')
results = result_container.find_elements_by_css_selector('.select2-results__option')
self.assertEqual(len(results), 1)
# Select the result.
search.send_keys(Keys.RETURN)
# Reopen the dropdown and add the first result to the selection.
elem.click()
search.send_keys(Keys.ARROW_DOWN)
search.send_keys(Keys.RETURN)
select = Select(self.selenium.find_element_by_id('id_related_questions'))
self.assertEqual(len(select.all_selected_options), 2)
示例7: press_down
# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import ARROW_DOWN [as 别名]
def press_down(self):
warnings.warn(
"deprecated; use `browser.element('#foo').type(Keys.ARROW_DOWN)` style instead",
DeprecationWarning)
return self.type(Keys.ARROW_DOWN)