Reputation: 439
I am new to selenium. I need to find a price display on a web page - 199. I am able to locate the element by
total_value = driver.find_element_by_id('items_total')
the html code is
<div class="quantity-value-total" id = "items_total">$199.00</div> == $0.
Is my line
total_value = driver.find_element_by_id('items_total')
assign the value of 199 to total value? Please help
Upvotes: 0
Views: 62
Reputation: 69
In Java you can use
String total_value= driver.findElement(By.id("items_total")).getText();
which will store the value $199.00
in a string total_value
Upvotes: 0
Reputation: 13970
No, the line
total_value = driver.find_element_by_id('items_total')
will not assign the value 199 to total_value
. Instead it will assign an object (HTML element), whose text is $199.00
. So you get that text using text
property:
total_value = driver.find_element_by_id('items_total').text
Note that total_value
will contain the full string ($199.00
), so you will need to manipulate it if you just want to get 199
as a number
Upvotes: 2