I want to select an option of an form using a Selenium to automate an task of download. Here're the steps of what i need to do:
1st. - Click into a bar of the "Formulário"
2st. - Select the option "Relatório de Emissão Tokio ID1000013"
I'm using the follow code to make theses steps, but in the end (in this part describe above) the code doesn't run.
from selenium import webdriver
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support.ui import Select
servico = Service(ChromeDriverManager().install())
navegador = webdriver.Chrome(service=servico)
navegador.implicitly_wait(10)
navegador.get('http://site.com.br')
navegador.implicitly_wait(10)
navegador.find_element('xpath', "//a[@id='linkMenu_1500']").click()
navegador.implicitly_wait(10)
navegador.find_element('xpath', "//a[@id='menu_1501']").click()
navegador.implicitly_wait(10)
navegador.find_element('xpath', "//a[@id='subMenu1000006']").click()
navegador.implicitly_wait(10)
element = navegador.find_element_by_xpath("//input[@id='id_formulario']")
But the code above returns this:
AttributeError Traceback (most recent call last)
Cell In[20], line 14
10 navegador.implicitly_wait(10)
11 # Selecione a opção "Relatório de Emissão Tokio" no formulário
12 #lect = Select(navegador.find_element_by_id("id_formulario"))
13 #elect.select_by_value("1000013")
---> 14 element = navegador.find_element_by_xpath("//input[@id='id_formulario']")
AttributeError: 'WebDriver' object has no attribute 'find_element_by_xpath'
Please, how can I do this tasks using Selenium?
Obs.: The page source code of this bar is:
<select class="form-control fichaCampo campoform" id="id_formulario" name="id_formulario" eng_idcoluna="1000835" title="Formulário" eng-possui-condicao="True" eng-executa-condicao-invisivel="False" eng-preenche-campos="dv_periodo,cd_tp_apolice,cd_status,nm_descricao" eng-index-linha="0" eng-sql-datatype="int" data-toggle="popover">
<option>
</option>
<option value="1000010">Acumulo por tomadores com Grupo Econômico ID1000010
</option>
<option value="592">Followup de Tomadores ID0000592
</option>
<option value="1000009">Gerencial - Cotação/Propostas/Estudos ID1000009
</option>
<option value="322">Gerencial - Produção por Periodo ID0000322
</option>
<option value="475">Relatório de Acúmulo Geral da Exposição do Tomador ID0000475
</option>
<option value="492">Relatório de Acúmulo Geral da Exposição do Tomador - CCG ID0000492
</option>
<option value="1000013">Relatório de Emissão Tokio ID1000013
</option>
<option value="366">Relatório de Emissões ID0000366
</option>
<option value="562">Relatório Geral de Tomadores ID0000562
</option>
<option value="1000007">Relatório Gerencie ID1000007
</option></select>