1

I am working on following link

I am not able to even extract first drop down too. I have been working with selenium version 3.14

I have written following code:

user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, " \
             "like Gecko) Chrome/100.0.4896.60 Safari/537.36"
options = webdriver.FirefoxOptions()
options.headless = False
options.add_argument(f'user-agent={user_agent}')
options.add_argument("--window-size=1920,1080")
options.add_argument('--ignore-certificate-errors')
options.add_argument('--allow-running-insecure-content')
options.add_argument("--disable-extensions")
options.add_argument("--proxy-server='direct://'")
options.add_argument("--proxy-bypass-list=*")
options.add_argument("--start-maximized")
options.add_argument('--disable-gpu')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--no-sandbox')
driver = webdriver.Firefox(executable_path=GeckoDriverManager().install(), options=options)
driver.get("https://election.gov.np/np/page/voter-list-db")
driver.implicitly_wait(5)

Select(WebDriverWait(driver, 5).until(EC.presence_of_element_located(
                (By.XPATH, "//select[@id='state']")))).select_by_value("5")
time.sleep(5)

I always get:

selenium.common.exceptions.TimeoutException: Message: 
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
lord stock
  • 1,191
  • 5
  • 32

1 Answers1

1

The element with the text as E-Mail Login is within an <iframe> so you have to:

  • Induce WebDriverWait for the desired frame to be available and switch to it.

  • Induce WebDriverWait for the desired element to be clickable.

  • You can use either of the following Locator Strategies:

    • Using XPATH:

      driver.get("https://election.gov.np/np/page/voter-list-db")
      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[@name='bbvrs']")))
      Select(WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.XPATH, "//select[@id='state']")))).select_by_value("5")
      
  • Note : You have to add the following imports :

     from selenium.webdriver.support.ui import WebDriverWait
     from selenium.webdriver.common.by import By
     from selenium.webdriver.support import expected_conditions as EC
    
  • Browser Snapshot:

EC_Nepal


Reference

You can find a couple of relevant discussions in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352