0
I see you have a similar question, but the answer still hasn’t helped me.
I need to collect data from the Central Bank. For this, I need to download the files that are in a drop down, one at a time.
However, I’m already having trouble selecting just one.
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support import expected_conditions as EC
import time
PATH = "/usr/local/bin/chromedriver" # É preciso baixar o driver do navegador e por na pasta, devem ser a mesma versao
driver = webdriver.Chrome(PATH)
driver.get("https://www.bcb.gov.br/acessoinformacao/legado?url=https:%2F%2Fwww.bcb.gov.br%2Ffis%2Finfo%2Finstituicoes.asp%3Fidpai%3DINFCAD")
driver.implicitly_wait(15)
select = Select(driver.find_element_by_id('Cooperativas')).click()
select.select_by_visible_text('Maio/2019').click()
driver.quit()
It opens Chrome, enters the site, waits the 15 seconds for the site to load, but gives the following error:
Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="Cooperatives"]"}
On the site, I have the select as follows:
<select id="Cooperativas" "parametro"="" name="PARAMETRO"> Cooperativas
<option value="/fis/info/cad/cooperativas/202005COOPERATIVAS.zip">Maio/2020</option>
(outros options embaixo)
I tried to use find_element_by_xpath
, but I got the same results.
Perfect! in the examples I saw, they went straight to select, they didn’t use the frame before. Thanks!
– RxT
Glad it worked out, whenever you have a popup, window, alert or frame you need to use switch_to() before to be able to interact
– edufgimenez
Thanks for the tip!
– RxT