I am new to python and selenium. Trying to automate download of files from the dropdown menu on the below link for the first time. The code gets stuck after page loads i.e the drop down does not work and gives me an error. Sorry if my code looks clunky. Any help is appreciated.
Thanks
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
import time
s=Service("C:\\python\\chromedriver.exe")
driver = webdriver.Chrome(service=s)
driver.maximize_window()
driver.get('http://www.amfiindia.com/research-information/aum-data/classified-average-aum')
#monthname=driver.find_element(By.XPATH,"//*[@id='AaumDate']")
monthdd=Select(monthname)
monthdd.select_by_value('01-Jan-22')
time.sleep(3)
typename=driver.find_element(By.XPATH,"//*[@id='AumType']")
typedd=Select(typename)
typedd.select_by_visible_text('Scheme category wise')
time.sleep(3)
mfname=driver.find_element(By.XPATH,"//*[@id='AumMFName']")
mfdd=Select(mfname)
mfdd.select_by_visible_text('All')
time.sleep(3)
driver.find_element("class name","sprite-inter go-btn").click()
CodePudding user response:
wait=WebDriverWait(driver,20)
driver.get('http://www.amfiindia.com/research-information/aum-data/classified-average-aum')
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR,"#divAumPeriod > span > a > span.ui-button-text"))).click()
wait.until(EC.element_to_be_clickable((By.XPATH,"//*[@class='ui-menu-item']/a[.='January - 2022']"))).click()
Most of these tags open like so and have another list with them that's not using the select tag.
Imports:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC