本文整理汇总了Python中selenium.webdriver.common.keys.Keys.UP属性的典型用法代码示例。如果您正苦于以下问题:Python Keys.UP属性的具体用法?Python Keys.UP怎么用?Python Keys.UP使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类selenium.webdriver.common.keys.Keys
的用法示例。
在下文中一共展示了Keys.UP属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: play
# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import UP [as 别名]
def play():
"""
Args:
None
Returns:
None
"""
driver = webdriver.Firefox(executable_path='/Users/keneudeh/Downloads/geckodriver')
driver.get('https://play2048.co/')
key_select = [Keys.UP, Keys.DOWN, Keys.LEFT, Keys.RIGHT]
gameStatusElem = driver.find_element_by_css_selector('.game-container p')
htmlElem = driver.find_element_by_css_selector('html')
while gameStatusElem.text != 'Game over!':
htmlElem.send_keys(key_select[random.randint(0, 3)])
gameStatusElem = driver.find_element_by_css_selector('.game-container p')
score = driver.find_element_by_css_selector('.score-container').text
print(f'You scored: {score}')
示例2: test_history_in_console
# 需要导入模块: from selenium.webdriver.common.keys import Keys [as 别名]
# 或者: from selenium.webdriver.common.keys.Keys import UP [as 别名]
def test_history_in_console(self, notebook):
notebook.edit_prompt_cell("a = 1", execute=True)
assert "" == notebook.get_prompt_content()
notebook.edit_prompt_cell("b <- 2", kernel="R", execute=True)
assert "" == notebook.get_prompt_content()
notebook.prompt_cell.send_keys(Keys.UP)
assert "b <- 2" == notebook.get_prompt_content()
notebook.prompt_cell.send_keys(Keys.UP)
assert "a = 1" == notebook.get_prompt_content()
# FIXME: down keys does not work, perhaps because the cell is not focused and
# the first step would be jumping to the end of the line
notebook.prompt_cell.send_keys(Keys.DOWN)
notebook.prompt_cell.send_keys(Keys.DOWN)
# assert 'b <- 2' == notebook.get_prompt_content()