'Asking Dropdown fo temperature input with selenium in python
Dear All in Stackover flow,
I need your help : I need to handle change input of bodytemperature
Picture of Web change body temperature

I need input this body temperature with random value between 35.8 - 36.5
This is inspect elements :
<input data-val="true" data-val-number="The field BodyTemperature must be a number." data-val-range="The field BodyTemperature must be between 33 and 43." data-val-range-max="43" data-val-range-min="33" data-val-required="The BodyTemperature field is required." id="BodyTemperature" max="43" min="33" name="BodyTemperature" step="0.1" type="text" value="36.1" data-role="numerictextbox" role="spinbutton" aria-valuemin="33" aria-valuemax="43" class="k-input" aria-valuenow="36.1" aria-disabled="false" style="display: none;">
And this is my code try
input_value = [36.10 ,36.20 ,36.30,36.50,35.80,35.90,35.80]
value = random.choice(input_value)
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,//input[@id='BodyTemperature'])).send_keys(value)
I hope Stackoverflow can help me
Please Help Me !!!!
Solution 1:[1]
For decimal values you have to use double, Please try the below, I have checked it it's giving the random number between 35.8 - 36.5.
double min = 35.8;
double max = 36.5;
double diff = max - min;
double randomValue = min + Math.random( ) * diff;
System.out.println(String.format("%.3g%n", randomValue))
Result: Like 36.1, 36.2, 35.9
Let us know if it didn't work for you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Akzy |
