我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用selenium.webdriver.common.keys.Keys.NULL。
def _map_ascii_key_code_to_key(self, key_code): map = { 0: Keys.NULL, 8: Keys.BACK_SPACE, 9: Keys.TAB, 10: Keys.RETURN, 13: Keys.ENTER, 24: Keys.CANCEL, 27: Keys.ESCAPE, 32: Keys.SPACE, 42: Keys.MULTIPLY, 43: Keys.ADD, 44: Keys.SEPARATOR, 45: Keys.SUBTRACT, 56: Keys.DECIMAL, 57: Keys.DIVIDE, 59: Keys.SEMICOLON, 61: Keys.EQUALS, 127: Keys.DELETE } key = map.get(key_code) if key is None: key = chr(key_code) return key
def test_performs_key_combinations(self, browser): receiver = browser.text_field(id='receiver') receiver.send_keys('foo') receiver.send_keys(MODIFIER + 'a' + Keys.NULL) receiver.send_keys(Keys.BACKSPACE) assert receiver.value == '' assert len(browser.element(id='output').ps()) == 6
def test_performs_arbitrary_list_of_key_combinations(self, browser): receiver = browser.text_field(id='receiver') receiver.send_keys('foo') receiver.send_keys(MODIFIER + 'a' + Keys.NULL + MODIFIER + 'x' + Keys.NULL) assert receiver.value == '' assert len(browser.element(id='output').ps()) == 7
def GetFocus(cls): log.step_normal(u"Element [%s]: GetFocus()" % (cls.__name__, )) # cls.__wait() WebDriverWait(env.driver, 10).until(lambda the_driver: the_driver.find_element(cls.by, cls.value).is_displayed()) elements = env.driver.find_elements(cls.by, cls.value) elements[cls.index].send_keys(Keys.NULL) action = webdriver.ActionChains(env.driver) action.send_keys_to_element(elements[cls.index], Keys.NULL) action.perform() cls.__clearup()