0

enter image description here

I want to get the number 31 in the shaded blue block here. So, I typed code.

val=driver.find_element_by_xpath("/html/body/div/table/tbody/tr[8]/td[2]")
print(val)

(The xpath of the box marked 31 is /html/body/div/table/tbody/tr[8]/td[2].)

But, I get

<selenium.webdriver.remote.webelement.WebElement (session="3e74d73f7dc4cd9a52b5430b7fa69678", element="0.771890890368685-1")>

What should I do to get the number 31? ^^

Brian
  • 5,069
  • 7
  • 37
  • 47
JAE_RYONG
  • 101
  • 1
  • 1
  • 5

1 Answers1

0

You're printing the entire element. An element is a complex object with a lot of attributes and such. But you really only want the text of the element.

So use:

print(val.text)

Corey Goldberg
  • 59,062
  • 28
  • 129
  • 143
John Gordon
  • 29,573
  • 7
  • 33
  • 58