lundi 7 décembre 2015

Python Selenium ActionChain script not working only Chrome?

I am writing a script to automate an user editing action. The app uses CKEditor, the steps is to first clear the content that is already in the editor and then type in new content. Here is the snippet of code:

ckeditor_frame = driver.find_element(By.XPATH, "//div[@id='cke_1_contents']/iframe")
driver.switch_to_frame(ckeditor_frame)
ckeditor_body = driver.find_element(By.XPATH, "//html/body")
actions = ActionChains(driver)
actions.move_to_element(ckeditor_body)
actions.key_down(Keys.COMMAND).send_keys('a')
actions.perform()
ckeditor_body.send_keys('This is a test')

This works perfectly in Firefox, but when I run the exact script in Chrome, it only insert the text (This is a text') the Alt-a action chain is totally omitted. I've googled and couldn't find any solution. Any expert can help?

Aucun commentaire:

Enregistrer un commentaire