Selenium chromedriver get element and fill form

You got this element in a wrong way.Selenium couldn’t find it.

If you just want to get the elements in first dropdown, try code below:

import time
from selenium import webdriver
import os

driver_path = r'pathtochromedriver\chromedriver.exe'
driver = webdriver.Chrome(driver_path)
driver.get('https://app.cpcbccr.com/ccr/#/caaqm-dashboard-all/caaqm-landing/data')
time.sleep(8) # sleep some time for waiting(It depends on your internet speed).You could also try WebDriverWait or implicitly_wait

elem = driver.find_elements_by_class_name('toggle')[0] # get the first dropdown button
elem.click() # click it.
 
dropdown = driver.find_element_by_css_selector('.options')
for state in dropdown.find_elements_by_css_selector('li'):
    print(state.text) # get the text in dropdown menu

And this gave me:

Andhra Pradesh
Assam
Bihar
Chandigarh
Delhi
Gujarat
Haryana
Jharkhand
Karnataka
Kerala
Madhya Pradesh
Maharashtra
Meghalaya
Mizoram
Nagaland
Odisha
Punjab
Rajasthan
Tamil Nadu
Telangana
Uttar Pradesh
West Bengal

Press F12 on this page,and:

enter image description here

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top