Skip to content
Advertisement

Failed to get only the “text” from “span” by selenium

this is my code:

JavaScript

my results:

JavaScript

site element:

JavaScript

I want to get only the number “16.98”, instead im getting the whole element. When im trying to write “.text” it returns “none”.

Advertisement

Answer

Instead .text use get_attribute('textContent') the element might be hidden on the page.

JavaScript

This should return $16.98 to get the 16.98 use string manipulation like

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement