1
element = browser.find_element_by_xpath("//div[@class='span12']")
    # send the copied text back 
context.bot.send_message(chat_id=update.message.chat_id, text=element)

#come error

element = browser.find_element_by_xpath("//div[@class='span12']")
2021-10-15 05:34:51,229 - telegram.ext.dispatcher - ERROR - No error handlers are registered, logging exception
........................
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type WebElement is not JSON serializable
furas
  • 134,197
  • 12
  • 106
  • 148
  • `JSON` can send only primitive types of data but you have object `WebElement`. You should manually convert it to string `text=str(element`)` but probably you should use `.text` to get text from this object. `text=element.text` – furas Oct 15 '21 at 03:16

2 Answers2

0

JSON can send only primitive types of data but you have object WebElement.

You should manually convert it to string

send_message(..., text=str(element) )

but probably you simply forgot .text to get text from this object.

send_message(..., text=element.text )
furas
  • 134,197
  • 12
  • 106
  • 148
0

I found a solution:
Add the following line to your code:

content = browser.find_element_by_id('report').text

Full example:

content = browser.find_element_by_id('report').text

# send the copid text back
context.bot.send_message(chat_id=update.message.chat_id, text=content)
Tyler2P
  • 2,324
  • 26
  • 22
  • 31