alexanderquispe/Diplomado_PUCP

Assigment_4

Opened this issue · 2 comments

Dear all,

  1. Follow the instructions in the Jupyter Notebook (JN) named as Assignment_4.
  2. Each group must create their branch named group_#_ass_4_2024_2 (group_1_ass_4_2024_2) and save their results in the Assignment_4 folder. Name your JN like your branch.
  3. Your Pull request should be linked to this issue.
  4. All the questions about the assignment should be posted in this issue.
  5. Deadline 17/08/2024 23:59.
Apg91 commented

Hi Anzony,

Our code doesn't run anymore all of a sudden. We think it may be a webpage error. How can we solve it?

Thank you,

Hi Everyone,

I do not know why the page presents errors, but you can use the following code before you run your scripts. It works!!!.

driver = webdriver.Chrome( ChromeDriverManager().install() )
# Maximize window
driver.maximize_window()

# go to the link
driver.get( 'https://www.onpe.gob.pe/elecciones/historico-elecciones/' )
# Go to Results
driver.find_element_by_xpath( "/html/body/div/div/div/section[2]/div/div[2]/div/div/div[2]/div/div[2]/a").click()
# See all tabs
driver.window_handles
# Go to the second tab
driver.switch_to.window(driver.window_handles[1])
# Click on Results
driver.find_element_by_xpath( "/html/body/onpe-root/onpe-home-onpe/div[1]/div/div/div/div[2]/div[2]/div/div/a" ).click()

# Give time to the page to refresh
time.sleep( 4 )

# Go to Extranjeros
scope = Select(driver.find_element_by_id( "select_ambito" ))
dict_scope_options = { option.text : option for option in scope.options }
dict_scope_options['EXTRANJERO'].click()