Here is the element obtained by inspect:
<span id="connected_modems">36</span>
I am trying to get the value 36
out of this element in Python.
When I try to print out the value 36
by following Python code,
element = driver.find_element_by_id("connected_modems")
for attr in element.get_property('attributes'):
print(attr['name'],attr['value'])
print("element value:", element.text)
I only get
class sstats
id connected_modems
element value: 0
When I try to find the value by view source of the webpage, the value is 0
instead of 36
, as following,
<span id="connected_modems">0</span>
How can I get the value 36
out of this element?
CodePudding user response:
You can try with element.get_attribute("innerHTML")
CodePudding user response:
Have you tried to get the element text by simply this:
element_text = driver.find_element(By.ID, "connected_modems").text