Performing a copy and paste with Selenium 2

0
0

Is there any way to perform a copy and paste using Selenium 2 and the Python bindings?

I’ve highlighted the element I want to copy and then I perform the following actions

copyActionChain.key_down(Keys.COMMAND).send_keys('C').key_up(Keys.COMMAND)

However, the highlighted text isn’t copied.

  • You must to post comments
0
0

Pretty simple actually:

from selenium.webdriver.common.keys import Keys
elem = find_element_by_name("our_element")
elem.send_keys("bar")
elem.send_keys(Keys.CONTROL, 'a') #highlight all in box
elem.send_keys(Keys.CONTROL, 'c') #copy
elem.send_keys(Keys.CONTROL, 'v') #paste

I imagine this could probably be extended to other commands as well

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website