You are on page 1of 1

while (succes == False):

# Fill in first form


cbox1 = driver.find_element_by_id("form")
all_options = cbox1.find_elements_by_tag_name("option")
for option in all_options:
if option.get_attribute("value") == '/icpplustiem/citar?p=28&locale=es':
option.click()
# Submit first form
driver.find_element_by_id("btnAceptar").click()

# Fill in second form


cbox2 = driver.find_element_by_id("tramiteGrupo[0]")
all_options = cbox2.find_elements_by_tag_name("option")
for option in all_options:
if option.get_attribute("value") == '4010':
option.click()
# Submit second form
driver.find_element_by_id("btnAceptar").click()

# Click third button


driver.find_element_by_id("btnEntrar").submit()

# Fill in third form


driver.find_element_by_id("txtIdCitado").send_keys(nie_value)
driver.find_element_by_id("txtDesCitado").send_keys(name_value)

cbox3 = driver.find_element_by_id("txtPaisNac")
all_options = cbox3.find_elements_by_tag_name("option")
for option in all_options:
if option.get_attribute("value") == '406':
option.click()
driver.find_element_by_id("txtFecha").send_keys(exp_date_value)
driver.find_element_by_id("btnEnviar").submit()

# Captcha solving time


captchaSolved = False
while (captchaSolved == False):
# Get user input
answer = raw_input('Did you solve captcha? ')
if answer == 'yes':
captchaSolved = True

# Click next buttons


driver.find_element_by_id("btnEnviar").submit()
driver.find_element_by_id("btnEnviar").click()

try:
assert "En este momento no hay citas disponibles." in
driver.page_source
driver.find_element_by_id("btnSalir").click()
except AssertionError:
succes = True
#print("Success")

You might also like