-1

i'm trying to make a program that waits for a certain value to be greater than or equal to a certain number and then do some actions.

PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)

driver.minimize_window()

driver.get("https://www.awstats.io/mining/pools/kavian")

try:
    element= WebDriverWait(driver, 30).until(EC.text_to_be_present_in_element((By.XPATH, '/html/body/div[3]/div[2]/table[1]/tbody/tr/td[3]'),'2.'))
    print(int(element))
except:
    print('time elapsed')
    pass

I need to execute an action only if the element value is greater or equal than 2 but i have no idea on how to wait for that instead of just the text. Any tips ?

neto
  • 19
  • 6

1 Answers1

0

Maybe this is not the best approach, but you can use something like this:

element = 0
WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, '/html/body/div[3]/div[2]/table[1]/tbody/tr/td[3]')))
for x in range(10): 
  element = driver.findelement_by_xpath('/html/body/div[3]/div[2]/table[1]/tbody/tr/td[3]').text    
    if(int(element) >= 2):
       print(int(element) >= 2)
    else:
      time.sleep(1)
if(int(element) < 2):
  print(Couldn't find expected value inside the element)

The code above is for element text value.
In case you are looking for element value attribute use text_to_be_present_in_element_value instead of text_to_be_present_in_element

Prophet
  • 32,350
  • 22
  • 54
  • 79