使用 Selenium WebDriver 和 python 按下 ENTER 键
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38312033/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ENTER key press using Selenium WebDriver with python
提问by user1537127
How can I simulate the ENTER key press using selenium python bindings? I have tried the following block but it is not working.
如何使用 selenium python 绑定模拟 ENTER 按键?我尝试了以下块,但它不起作用。
driver.find_element_by_xpath("html/xxxxx").send_keys('keys.ENTER')
or
或者
driver.find_element_by_name("element_name").send_keys("ENTER")
回答by Alichino
Use these codes from the API docs: http://selenium-python.readthedocs.io/api.html#module-selenium.webdriver.common.keys
使用 API 文档中的这些代码:http: //selenium-python.readthedocs.io/api.html#module-selenium.webdriver.common.keys
Eg. ENTER would be .send_keys(u'\ue007')
例如。ENTER 将是.send_keys(u'\ue007')
回答by d_rez90
Try keys.ENTER
, not as a string. take the single quotes off of it.
尝试keys.ENTER
,而不是作为字符串。去掉单引号。