0

I am trying to send an email, which is done with HTML and CSS, with Selenium, it appears that it can't get the page itself, only the text, or the code, so is there a way to copy the page.

Tried:

  1. Sending Keys, (Keys.CONTROL + 'A').... (Keys.CONTROL + 'C') and assigning it to a var but didn't get what I want.

  2. Constructing a field in the beginning and manually copy the content and paste it in the field, then getting its value, but same thing, it only gets the text.

4
  • You want to print the text on the web page? Commented Jul 25, 2021 at 16:23
  • no I want to send an email with an html content, so that I can make more designs with css and html, you know ... Commented Jul 25, 2021 at 16:25
  • For Those who don't know, you can copy a page content and send it in an email, with all its functions and design Commented Jul 25, 2021 at 16:26
  • Can you show the code which you tried ? Commented Jul 25, 2021 at 16:34

2 Answers 2

2

Basically you need to get the outerHTML attribute from the target element.

Let's say you want to store all the HTML content (tags and text) from the contentEmail ID:

<div id="contentEmail">
   <span>
     My content email here!
     <br>
   </span>
</div>

To do this, you need this:

html_content = self.find_element(By.ID, "contentEmail").get_attribute("outerHTML")
print(html_content)
Sign up to request clarification or add additional context in comments.

Comments

0

I found it,

the Sending Keys,

(Keys.CONTROL + 'A')

(Keys.CONTROL + 'C') worked but I just needed to send (Keys.CONTROL + 'V') Not assigning it to a var

3 Comments

Why would you do that ? You can get page resource in Selenium as well.
ok you can answer, and I will see if it is a more productive way
I need to copy HTML + CSS Page to send it in an email, is there a better way

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.