0

Is there any method for me to get the text "ABCD" as below HTML? I just know get the emement , but have no idea about to get its text.

element1= find_element_by_xpath("//caption/em")

Then how can I get "ABCD", is there any method like gettext()?

<table class='1'>
    <caption>
        <em> ABCD </em>
    </caption>
 </table>
Stella
  • 1,504
  • 2
  • 16
  • 25

2 Answers2

2

Access the text using text attribute:

>>> element1.text
u'ABCD'
falsetru
  • 357,413
  • 63
  • 732
  • 636
0
element1= find_element_by_xpath("//caption/em")
element1.get_attribute('innerHTML') 

And I found Beautiful Soup will be more better to get text.

Stella
  • 1,504
  • 2
  • 16
  • 25