0
I’m writing a code to automate some processes on the SIAFI site, I couldn’t get Python to click on a checkbox, except by importing the package pynput
and using the mouse positioning function with the coordinates (x, y):
from pynput.mouse import Button, Controller
mouse = Controller()
After I imported I used the code below to click exactly on this location:
mouse.position (121,278)
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 field of checkbox 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">