Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

219
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda