I have a list containing hundreds of data in the format
[
'5008489',
'Órgão: MPF',
'PROCEDIMENTO DO JUIZADO ESPECIAL',
'CPF',
<selenium.webdriver.remote.webelement.WebElement (session="8834847081a4be257906cce85807f88a", element="0.34327825856075167-261")>,
'SERGIO AUGUSTO NOME FICTICIO'
]
Since item 0 is the process number, the penultimate item is the corresponding checkbox and the last one is the CURRENT person.
I also have another list with all POSSIBLE RESPONSIBLE.
Finally, I have a list with several processes, which I need to REDISTRIBUTE for NEW RESPONSIBLE.
I thought of doing the following:
1 - Identify, in the list of processes to be redistributed, who will be responsible for new processes;
2 - From the first name, select all processes that will go to it;
3 - Click on the respective checkbox;
4 - Finish the distribution.
I have done the following function, but it does not seem satisfactory:
def DistribuiProcesso():
distribuir = Select(browser.find_element_by_id('listaResponsaveis'))
responsaveis = distribuir.options
for x in range(len(responsaveis)):
for y in range(len(processosAlvo)): #Iterando a lista dos processos que serão redistribuidos...
for z in range(len(processosAlvo[y])): #Iterando os itens de cada processo...
if z == len(processosAlvo[y]) - 1: #Localizando o item que contém o nome do responsável...
responsavelAlvo = processosAlvo[y][z]
if responsavelAlvo == responsaveis[x].text:
if z == len(processosAlvo[y]) - 2: #Localizando o item que contém o checkbox...
processosAlvo[y][z].click()
I ask your help to come up with a better reasoning.