Issue
Can I control + A and then somehow get the text that was highlighted with the control + A? All in Selenium Python.
Solution
I think something like this should work
from selenium.webdriver.common.keys import Keys
src_elem = find_element_by_name("source_element")
dist_elem = find_element_by_name("distance_element")
src_elem.send_keys(Keys.CONTROL + 'a') # select all the text
src_elem.send_keys(Keys.CONTROL + 'c') # copy it
dist_elem.send_keys(Keys.CONTROL + 'v') # paste
In case that is not enough try clicking on the element before sending keys to it, like this:
from selenium.webdriver.common.keys import Keys
src_elem = find_element_by_name("source_element")
dist_elem = find_element_by_name("distance_element")
src_elem.click()
src_elem.send_keys(Keys.CONTROL + 'a') # select all the text
src_elem.send_keys(Keys.CONTROL + 'c') # copy it
dist_elem.click()
dist_elem.send_keys(Keys.CONTROL + 'v') # paste
Answered By - Prophet
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.