我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用selenium.webdriver.common.keys.Keys.RIGHT。
def press_key(element, key): """Press a given key in the element. Parameters: element : element key : value """ step_message = 'Press key: {}'.format(key) execution.logger.info(step_message) _capture_or_add_step(step_message, execution.settings['screenshot_on_step']) webelement = get_browser().find(element) if key == 'RETURN' or key == 'ENTER': webelement.send_keys(Keys.RETURN) elif key == 'UP': webelement.send_keys(Keys.UP) elif key == 'DOWN': webelement.send_keys(Keys.DOWN) elif key == 'LEFT': webelement.send_keys(Keys.LEFT) elif key == 'RIGHT': webelement.send_keys(Keys.RIGHT) else: raise Exception('Key value {} is invalid'.format(key))