-1

Okay, so I'm trying to find the 179 in:

<span class="totalcount">179</span>

However, for some reason:

maxpage = driver.find_element_by_class_name('totalcount') 

results in maxpage being set equal to:

<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="2c241847-ac56-4ed5-bb0e-73b473833ce4", element="9f837b6e-e78f-4fca-87b8-4efcb463e5a3")>

But I want to get value equal to 179. Do you have any advice?

Koen Meijer
  • 811
  • 11
  • 19
ksmiles
  • 91
  • 1
  • 10
  • Possible duplicate of [How to locate an element by class name and its text in python selenium](https://stackoverflow.com/questions/26370554/how-to-locate-an-element-by-class-name-and-its-text-in-python-selenium) – Van Peer Nov 13 '17 at 14:12
  • Did you try my answer? If it was helpful -- check a tick near my answer, please. Thanks. – Ratmir Asanov Jan 11 '18 at 13:12

3 Answers3

3

maxpage is instance of WebElement class. Use maxpage.text to get content.

esra
  • 189
  • 3
1

The command driver.find_element_by_class_name('totalcount') returns a WebElement.

Such instance includes a number of things, like the position of the element, if it is visible/clickable etc. You must use .text to find the "value" of you element. Try the following:

maxpage = driver.find_element_by_class_name('totalcount').text or maxpage.text and assign it to a string.

0

You can also use maxpage.get_attribute("value").

Ratmir Asanov
  • 6,237
  • 5
  • 26
  • 40