I am new to python selenium. I want to click the Iniciar session(Login button) on this web site. I have tried using the XPath, CSS selector, CSS Path, and class name.
I use the below code to click the button:
from selenium import webdriver
from selenium.webdriver.common.by import By
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--incognito')
options.add_argument('--headless')
driver = webdriver.Chrome("C:/Users/pralo/Downloads/DE/chromedriver", chrome_options=options)
driver.get('https://www.panamacompra.gob.pa/Inicio/#/')
sleep(10)
driver.find_element(By.XPATH,'//button[text()=" Iniciar sesión"]').click()
I get the below error for the above code execution:
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element is not clickable at point (389, 1470)
Can anyone help me understand the reason for this error?
CodePudding user response:
You can utilize the driver.execute_script()
method:
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
driver = webdriver.Chrome()
driver.get('https://www.panamacompra.gob.pa/Inicio/#/')
sleep(10)
element = driver.find_element(By.CLASS_NAME, 'btn-blue-dark')
driver.execute_script("arguments[0].click();", element)
The driver.execute_script()
method allows you to run JavaScript code in your Python program!