Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

222
Vistas
ElementClickInterceptedException: clic del elemento interceptado: no se puede hacer clic en el elemento en el punto de error al hacer clic en el botón Buscar usando Selenium Python

Quiero raspar el siguiente sitio web: https://sprs.parl.gov.sg/search/home

Pero cuando mi código hace clic en el "botón Buscar", aparece el error:

 ElementClickInterceptedException: element click intercepted: Element is not clickable at point (320, 1395)

No estoy seguro si es porque el botón Buscar no está completamente visible y necesita desplazarse hacia abajo. Si es así, ¿cómo me desplazo hacia abajo en la página usando Selenium?

Pruebas de código:

 from bs4 import BeautifulSoup as bs from selenium import webdriver import time driver = webdriver.Chrome(executable_path="C:/Users/chromedriver.exe") page_url = 'https://sprs.parl.gov.sg/search/home' driver.get(page_url) # Get search box and fill it up search = driver.find_element_by_css_selector('#divmpscreen2 > div.row > div:nth-child(1) > div > div:nth-child(1) > input') search.send_keys('COS') # This will select the 13th parliament session = driver.find_element_by_xpath("//select/option[contains(text(), '13th')]") session.click() time.sleep(10) # Find submit element and click submit = driver.find_element_by_xpath("//button[@label='Search']/em") submit.click()
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

Para hacer clic en el botón Buscar , debe inducir WebDriverWait para element_to_be_clickable() y puede usar la siguiente estrategia de localización :

 driver.get('https://sprs.parl.gov.sg/search/home') WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#divmpscreen2 > div.row > div:nth-child(1) > div > div:nth-child(1) > input"))).send_keys('COS') Select(WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//label[text()='By Parliament']//following-sibling::select[1]")))).select_by_value('13: 13') driver.execute_script("arguments[0].click();", WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='btn btn-black' and @label='Search']/em"))))

Instantánea del navegador:

Resultados de la búsqueda

Nota : debe agregar las siguientes importaciones:

 from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC
about 4 years ago · Juan Pablo Isaza Denunciar

0

Podemos intentar hacer clic usando mover al elemento o usando el ejecutor de script java

 Actions action = new Actions(webdriver); WebElement we = webdriver.findElement(By.xpath("path here")); action.moveToElement(we).click().build().perform();

usando javascript

 WebElement element = driver.findElement(By.id("gbqfd")); JavascriptExecutor executor = (JavascriptExecutor)driver; executor.executeScript("arguments[0].click();", element);
about 4 years ago · Juan Pablo Isaza Denunciar

0

Esta es una forma de seleccionar la información deseada y hacer clic en ese botón (EDITAR: una mejor manera sin ActionChains, y trabajando también en ventanas de menor tamaño):

 from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import Select import time as t chrome_options = Options() chrome_options.add_argument("--no-sandbox") chrome_options.add_argument('disable-notifications') chrome_options.add_argument("window-size=1280,720") webdriver_service = Service("chromedriver/chromedriver") ## path to where you saved chromedriver binary browser = webdriver.Chrome(service=webdriver_service, options=chrome_options) url = 'https://sprs.parl.gov.sg/search/home' browser.get(url) searchbox = WebDriverWait(browser, 20).until(EC.presence_of_element_located((By.XPATH, "//label[contains(text(), 'By Keyword')]/following-sibling::input"))) print(searchbox.location_once_scrolled_into_view) searchbox.send_keys('COS') govt_nr = Select(WebDriverWait(browser, 20).until(EC.presence_of_element_located((By.XPATH, "//label[contains(text(), 'By Parliament')]/following-sibling::select")))) govt_nr.select_by_index(13) browser.execute_script("window.scrollTo(0,document.body.scrollHeight);") t.sleep(1) submit_button = WebDriverWait(browser, 20).until(EC.presence_of_element_located((By.CSS_SELECTOR, "button[label = 'Search']"))) submit_button.click()

La configuración es linux/chromedriver, solo tiene que observar las importaciones y el código después de definir el navegador/controlador.

Documentos de Selenium: https://www.selenium.dev/documentation/

Una cosa más a tener en cuenta: los resultados se abrirán en una nueva pestaña, por lo que deberá cambiar a ella usando algo como switch_to.window(driver.window_handles[-1]) .

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda