Solution for How to extract a value coming from selenium driver.find_element_by_id
is Given Below:
I am trying to automate some test cases, for on test case I need a particular temperature value in integer. However, the value coming from
see when you do,
it is gonna return a string.
so it will look like this “12°C”
see below, we will split using
'°', this and we will have an array, and we would be interesting in first element of that. Below is the full demonstration.
s = "12°C" a = s.split('°') print(type(s)) b = int(a) print(b)
You can extract number from a string with this:
import re print (re.findall('d+', str1 ))
Where str1 is a string you extracting from a web element