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,039
  • 7
  • 35
  • 45
JAE_RYONG
  • 91
  • 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
  • 56,214
  • 26
  • 121
  • 139
John Gordon
  • 23,292
  • 7
  • 28
  • 49