2015-11-25 67 views
1

我在執行硒代碼時出現錯誤。錯誤:類型對象'Keys'沒有屬性'和絃'

代碼:

driver.find_element_by_id(PlaylistManagerLocators.Folder_Name).send_keys(Keys.chord(Keys.CONTROL, "a"), "Auto_Folder5763") 

錯誤:

AttributeError: type object 'Keys' has no attribute 'chord'

我已經導入的所有必需的文件。

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")   

回答

3

沒有的功能,如selenium.webdriver.common.keys.Keyschord(檢查文檔)。你可以簡單地將它分成2個語句。

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鍵。

+0

是它爲我工作用下面的代碼:driver.find_element_by_id(PlaylistManagerLocators.Folder_Name).send_keys(Keys.CONTROL, 'A') driver.find_element_by_id(PlaylistManagerLocators.Folder_Name).send_keys(Keys.DELETE) 驅動程序。 find_element_by_id(PlaylistManagerLocators.Folder_Name).send_keys(「Auto_Folder5764」) driver.find_element_by_id(PlaylistManagerLocators.Folder_Name).send_keys(Keys.ENTER) –

相關問題