I am trying to give input to the 'Currency I have' text box. This input is in the variable 'currency'. After I give the input in the text box, it displays a number of options. I want to do a case insensitive match on the 3 letter currency code I enter and the options the text box displays in the drop-down, and select the correct one. The page I am testing: https://www.oanda.com/fx-for-business/historical-rates
currency = currency_list.loc[i,'currency']
print(f'\nFETCHING DATA FOR : {currency}')
df=pd.DataFrame()
#input our currency in "currency I have" text-box
WebDriverWait(driver, 2).until(EC.presence_of_element_located((By.CSS_SELECTOR,'#havePicker > div'))).click()
currency_have = WebDriverWait(driver, 2).until(EC.presence_of_element_located((By.CSS_SELECTOR,'#havePicker > div > input')))
try:
currency_have.clear()
except:
pass
currency_have.send_keys(currency)
options = WebDriverWait(driver, 2).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR,'#havePicker > div > ul li')))
div_tags = [li_tags.find_elements_by_tag_name('div') for li_tags in options]
for div_tag in div_tags:
test = div_tag[1]
if (test.text.casefold()) == (currency.casefold()):
return test
else:
continue
The return statement in my code is incorrect. How do I proceed further to achieve my goal?
Please, any help would be appreciated.