I successfully highlight the section in a web page, but send_keys, .send_keys(Keys.CONTROL, "c")
, does not place the intended text to copy in clipboard, only the last thing I manually copied is in clipboard:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.somesite.com")
driver.find_element_by_id("some id").send_keys(Keys.CONTROL, "a") #this successfully highlights section I need to copy
elem.send_keys(Keys.CONTROL, "c") # this does not actually copy text**
I tried then using the Firefox edit menu to select all and copy text, but didn't work either and cant find anything online to assist other than possible mention of a bug (tried old version of Firefox, but didn't solve issue). Any ideas?
Try using the code below:
Include the header below to import ActionChains
from selenium.webdriver.common.action_chains import ActionChains
actions = ActionChains(driver)
actions.key_down(Keys.CONTROL)
actions.send_keys("c")
actions.key_up(Keys.CONTROL)
Try this:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.somesite.com")
driver.find_element_by_id("some id").send_keys(Keys.CONTROL, "a")
driver.find_element_by_id("some id").send_keys(Keys.CONTROL, "c")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With