Home > Back-end >  How to remmember element value and use it later in Selenium Python
How to remmember element value and use it later in Selenium Python

Time:02-04

I have a number field in a website and i want to save its value let's suppose its 150 i want to do like if the new number is bigger than its old value print "yes it's big"

num = driver.find_element_by_id("numField")
# and then some clicks and instructions and some changes in its value
if num>num:
   print("yes it's big")

CodePudding user response:

You can get the new value of that element again and then compare between the values.
I think you wanted to extract the element text?
If so you code could be something like this:

initial_num = driver.find_element_by_id("numField").text
# and then some clicks and instructions and some changes in its value
new_num = driver.find_element_by_id("numField").text
if new_num>initial_num:
   print("yes it's big")
  •  Tags:  
  • Related