How can send HTML from Selenium using sendKeys

Rate this post

I have a HTML code that I made using –

find_all(["h2", "h3", "h4", "h5", "ul", "p", "h6"])

So, it has code like below –

<p>Hello this is a paragraph</p>
<h2>This is a Sub Heading</h2>

I want to send this whole HTML using send keys to my WordPress post, but it returns the error

return self.attrs[key] KeyError: 0

If I use .text or .contents, I can send, however it removes the HTML tags. I want to send them including the tags, how can I do so?



Try this code it’s working on here :

from seleniumwire import webdriver
from import ChromeDriverManager
from selenium.webdriver.common.keys import Keys
from import Options

chrome_options = Options()
browser = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=chrome_options)
search = browser.find_element_by_xpath('/html/body/div[1]/div[3]/form/div[1]/div[1]/div[1]/div/div[2]/input')
html_text = """
<p>Hello this is a paragraph</p>
<h2>This is a Sub Heading</h2>


maybe the problem is on text treatment

Leave a Reply

Your email address will not be published.

Back to top button