0

trying to scrape a website using selenium. the following code works fine.

import selenium
import numpy as np
from tqdm import tqdm
import time
import pandas  as pd
from selenium import webdriver as wb
time.sleep(2)
driver=wb.Chrome('chromedriver.exe')
driver.maximize_window()
driver.get('https://www.jumia.co.ke/')
button = driver.find_element_by_xpath('//*[@id="jm"]/div[4]/section/button').click();
move=driver.find_element_by_xpath('//*[@id="jm"]/div[3]/button').click(); 
time.sleep(3)
clickObj=driver.find_element_by_xpath('//* 
[@id="jm"]/main/div[1]/div[1]/div[1]/div/a[5]/span')
clickObj.click()

however am getting an error running code below, although the chrome driver clicks on the page: when I rerun again, the error disappears.

gash=driver.find_element_by_xpath('//*[@id="ctlg"]/div/div[2]/div/div/a[2]/p')
gash.click()

the error:

ElementClickInterceptedException          Traceback (most recent call last)
<ipython-input-3-79a9b5b24451> in <module>
  1 gash=driver.find_element_by_xpath('//*[@id="ctlg"]/div/div[2]/div/div/a[2]/p')
----> 2 gash.click()

~\anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py in click(self)
 78     def click(self):
 79         """Clicks the element."""
---> 80         self._execute(Command.CLICK_ELEMENT)
 81 
 82     def submit(self):

~\anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py in _execute(self,   
 command,     params)
631             params = {}
632         params['id'] = self._id
--> 633         return self._parent.execute(command, params)
634 
635     def find_element(self, by=By.ID, value=None):

~\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in execute(self, 
driver_command, params)
319         response = self.command_executor.execute(driver_command, params)
320         if response:
--> 321             self.error_handler.check_response(response)
322             response['value'] = self._unwrap_value(
323                 response.get('value', None))

 ~\anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py in 
 check_response(self, response)
240                 alert_text = value['alert'].get('text')
241             raise exception_class(message, screen, stacktrace, alert_text)
--> 242         raise exception_class(message, screen, stacktrace)
243 
244     def _value_or_default(self, obj, key, default):

 ElementClickInterceptedException: Message: element click intercepted: Element is not 
 clickable at point (313, 748)
 (Session info: chrome=87.0.4280.88)

how can I solve this error? Kindly include an example

DENNYS WANDIA
  • 23
  • 1
  • 5
  • The error states " Element is not clickable at point ..." therefore the element cannot be clicked on. Perhaps it is behind something. Try pasting your xpath into the console and finding it directly, and seeing what it looks like in the browser. https://stackoverflow.com/questions/22571267/how-to-verify-an-xpath-expression-in-chrome-developers-tool-or-firefoxs-firebug – Paul Collingwood Dec 21 '20 at 16:00
  • Can you update the question with the steps you are trying to follow to reproduce the error? – undetected Selenium Dec 21 '20 at 16:01

1 Answers1

0

Use the following code to resolve this issue

browser.execute_script("arguments[0].click();", "name of button ")