How to click on a checkbox when another element obscure it?

0

I am writing a code to automate some processes in the SIAFI site, I could not make python click on a checkbox, other than importing the pynput package and using the mouse position with the coordinates (x, y):

from pynput.mouse import Button, Controller
mouse = Controller()

After I imported, I used:

mouse.position (121,278)

To click exactly on this location, the problem is that if I use this script on a different monitor, I have to modify the coordinates (x, y). I wanted python to recognize the checkbox field and click on it, regardless of the coordinates.

elemento11 = wait.until(EC.element_to_be_clickable((By.ID, 'formComp:tabelaPesquisarCompromissos:marcaTodas')))
elemento11 = browser.find_element_by_id('formComp:tabelaPesquisarCompromissos:marcaTodas')
mouse.position = (121, 278)#levar o mouse até a posição DEPENDENDO SE A PÁGINA FOR A ÚLTIMA PODE VARIAR
mouse.click(Button.left, 1)#clicar em selecionar todas
elemento12 = wait.until(EC.element_to_be_clickable((By.ID, 'formComp:botao_marcar_opcao_realizacao')))
time.sleep(int(segundos))

Below I will describe the html code of the siafi web page:

<input id="formComp:tabelaPesquisarCompromissos:marcaTodas" name="formComp:tabelaPesquisarCompromissos:marcaTodas" onclick="selecionarTodos(this);" type="checkbox">
    
asked by anonymous 20.03.2018 / 15:22

1 answer

0

It was not clear to me why you can not click this checkbox. Is it because it's hidden or because it only appears based on other checkboxes?

One solution that the QA team found in my work was to create a method that checks to see if the element is visible, and then to execute something.

Something like (I'm writing from my head, I do not know if it works):

def esperar_por_elemento():
    tentativas = 0
    while tentativas < limite_de_tentativas:
    if browser.find_element_by_id()
        break
    sleep(ALGUM_TEMPO_PRA_ESPERAR)
    tentativas += 1
    return browser.find_element_by_id()

The idea is more or less this.

    
29.03.2018 / 14:30