Python selenium.webdriver.common.keys.Keys.UP Examples
The following are 2
code examples of selenium.webdriver.common.keys.Keys.UP().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
selenium.webdriver.common.keys.Keys
, or try the search function
.
Example #1
Source File: 2048.py From automate-the-boring-stuff-projects with MIT License | 5 votes |
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}')
Example #2
Source File: test_frontend.py From sos-notebook with BSD 3-Clause "New" or "Revised" License | 5 votes |
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()