title: How to select, copy and paste everything within an element using selenium webdriver (python)
body: <p>Here is basically what I'm trying to do. I have 2 websites, website A contains the data I need to move over to website B. In essence</p>
  <blockquote>
  <p>I'm migrating data from website A to B as website A is going down
  soon.</p>
  </blockquote>
  <p>What I need to move is <strong>not just text, it can be text, images or hyperlinked text, aswell as there is some format things that I need to keep</strong>. I think It is simplest to copy and past rather then store all of this data in a way that would allow me to insert it to website B the exact same way as if it was copy and pasted. Before me making a code solution they where just literally copying and pasting everything from A to B. Right now I have everything implemented(getting of links and everything else required) in my code but I cant move the data over. So basically here's what I'm doing right before I try to copy and paste the data. I am using python 3.</p>
  <pre><code>            original_window = driver.current_window_handle
              driver.execute_script(&quot;window.open()&quot;)
              wait.until(EC.number_of_windows_to_be(2))
              driver.switch_to.window(driver.window_handles[1])
              actURL = a.getlink()
              driver.get(actURL)
              e = a.getactivitydata(driver)
              driver.close()
              driver.switch_to.window(driver.window_handles[0])
  </code></pre>
  <p>Here A is a custom object and has the method get link which returns the link to website A that i need the data from. A also contains the method getactivitydata, which is where I want to select, copy and return the driver. The methods code is</p>
  <pre><code>def getactivitydata(self, driver):
      r = driver.page_source
      soup = BeautifulSoup(r, 'html.parser')  # Raw html obj
      ty = self.typef
      if ty == 'page':
          elem = driver.find_element_by_id(&quot;page-content&quot;)
          end = driver.find_element_by_class_name('course-nav')
          a = ActionChains(driver)
          #elem.send_keys(&quot;bar&quot;)
          a.move_to_element(elem)
          a.click_and_hold().perform()
          driver.execute_script(&quot;window.scrollTo(0, document.body.scrollHeight);&quot;)
  
          a.move_to_element(end)
          a.key_down(Keys.CONTROL).send_keys('c').key_up(Keys.CONTROL).perform()
  
          #elem.send_keys(Keys.CONTROL, 'a')  # Select all
          #elem.send_keys(Keys.CONTROL, 'c')  # Copy
          return(elem)
  
      elif ty == 'quiz':
          pass
      elif ty == 'assign':
          pass
      elif ty == 'folder':
          pass
      elif ty == 'glossary':
          pass
      elif ty == 'resource':
          pass
      elif ty == 'forum':
          pass
  </code></pre>
  <p>ty represents the type of page as each page will need to be handled slightly differently. What I want this to do is basically select all of the text and images that is inside of the HTML with the element id 'page-content'. When ran the code(with plenty of other code that works) I get the following exception</p>
  <pre><code>selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
  </code></pre>
  <p>This exception is being raised on the line where I try to actually copy the data I need.</p>
  <p>While <strong>the element that actually contains the text is &lt;h1, &lt;h2... ect.</strong>(its closed &gt;, this is my first time posting and I cant figure out how to get stack overflow to display it with it closed) <strong>Images are contained by &lt;img,</strong> If I was to somehow run a loop through all of thease and highlight them all then copy and paste, how would I do that <strong>preserving the order the images show up within the text</strong> and how would I get the amount of &lt;hn  as it would be different for every page. I have tried a few different elements/ methods to try to select and copy the text and so far I have not been able to successfully highlight any text(That I can visually see, I use chrome webdriver 89).</p>
  <p>The smallest HTML tag they all belong to is &lt;div class =&quot;row&quot; and there are multiple rows on even a basic single box of text/images.</p>
  <p>Any help or guidance is welcomed, I'm not against using another method other then copy/paste but I do need it to output on website B as if it had been copy/pasted. as well there are types of pages that have multiple separate elements, (Like an online quiz, where you have question 1, a)... , b...) ... question 2) ect...) <strong>Thank you!</strong></p>