错误:类型对象“键"没有属性“和弦" [英] Error: type object 'Keys' has no attribute 'chord'
本文介绍了错误:类型对象“键"没有属性“和弦"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在执行硒代码时遇到错误.
I am getting below error while executing selenium code.
代码:
driver.find_element_by_id(PlaylistManagerLocators.Folder_Name).send_keys(Keys.chord(Keys.CONTROL, "a"), "Auto_Folder5763")
错误:
AttributeError:类型对象"Keys"没有属性"chord"
AttributeError: type object 'Keys' has no attribute 'chord'
我已经导入了所有必需的文件.
I have imported all required files.
from selenium.webdriver.common.keys import Keys
from selenium.webdriver import ActionChains
driver.find_element_by_id(PlaylistManagerLocators.Folder_Name).send_keys(Keys.chord(Keys.CONTROL, "a"), "Auto_Folder5763")
推荐答案
There is no function as chord
in class selenium.webdriver.common.keys.Keys
(Check the docs). You can simply split it into 2 statements.
driver.find_element_by_id(id).send_keys(Keys.CONTROL + "a")
driver.find_element_by_id(id).send_keys("Auto_Folder5763")
或者如果您想同时按下按键,则可以尝试使用 selenium.webdriver.common.action_chains.ActionChains
.
Or if you want to simultaneously have the keys pressed then you can try using selenium.webdriver.common.action_chains.ActionChains
.
这篇关于错误:类型对象“键"没有属性“和弦"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文