Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save pr0nstar/d959bc76c7e1293616ccda18955e6184 to your computer and use it in GitHub Desktop.

Select an option

Save pr0nstar/d959bc76c7e1293616ccda18955e6184 to your computer and use it in GitHub Desktop.
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.support.ui import WebDriverWait
options = Options()
options.add_argument('--headless')
driver = webdriver.Firefox(options)
driver.get('http://reportes-siahv.minsalud.gob.bo/Reporte_Dinamico_DG.aspx')
def click_n_wait(button, timeout=5):
source = driver.page_source
button.click()
def compare_source(driver):
try:
return not button.is_displayed()
except Exception as e:
return True
WebDriverWait(driver, timeout).until(compare_source)
def look_for_options(name):
return driver.find_element_by_name(name).find_elements_by_tag_name('option')
# Aqui deberia buclear por un range(1, 10) los sedes y range(-3, 0) las gestiones
click_n_wait(look_for_options('ctl00$ContenidoPrincipal$ddl_sedes')[1])
click_n_wait(look_for_options('ctl00$ContenidoPrincipal$ddl_gestion')[-1])
click_n_wait(
driver.find_element_by_name('ctl00$ContenidoPrincipal$BTNGenerar')
)
click_n_wait(
driver.find_element_by_name('ContenidoPrincipal_ASPxButton1_CD')
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment