I am new to Python and I am trying to click on the following button with HTML structure:
<div class="buttons">
<input name="ctl00$cphMain$mscSeats$tabStatus$btnDeviceMissingModal" value="Dispositivo" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$cphMain$mscSeats$tabStatus$btnDeviceMissingModal", "", true, "", "", false, false))" id="cphMain_mscSeats_tabStatus_btnDeviceMissingModal" class="modal btnRed border-radius cboxElement" href="#pnlReportMissingConfirm" type="submit">
</div>
I tried using the following code:
element = driver.find_element_by_xpath("//input[@name='ctl00$cphMain$mscSeats$tabStatus$btnDeviceMissingModal']")
element.click()
To avoid timing problems when looking for elements, it is recommended to use selenium classes like Wait or FluentWait. FluentWait looks for the element and if it does not find it, it looks for it every x time, that you indicate, up to a maximum time y.
For example, in your case it would fetch the input every second for 10 seconds. This way you don't have to modify the sleep depending on how long it takes each time.
I use java for selenium and it looks something like this, to search for a clickable element, for example: