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">