Selenium : Element is not clickable at point (X,Y)

Now a days most of them using selenium as one of the scraping tool due to its build in library and community support. Even though many of us feel its hard to implement in selenium.  In my previous post  explained how  effectively we can use the selenium in different use cases. Most of us known selenium is a automation testing tool. Currently people using this as most successful scraping methodology.  The most scraping tools are developed with the help of selenium only.  For example Scrapy .

To know more about how to crawl a website follow this post http://ramakavanan.blogspot.com/2017/09/website-crawl-or-scraping-with-selenium.html.

Issue:

One day I started to crawl  Cricbuzz website. In the middle of crawling, The crawler should move to the next page. So I want not click the "next"  button in the pagination list.  But the crawler throws the issue like

WebDriverException: Message: Element is not clickable at point (918, 13). Other element would receive the click:

to resolve this, I tried to solve in using the below code ,

 driver.find_element_by_class_name('pagination-next').click()

It does not solved fully. It works partially . So I tried another way to solve and code is

driver.implicitly_wait(10)
el = driver.find_element_by_class_name('pagination-next')
action = webdriver.common.action_chains.ActionChains(driver)
action.move_to_element_with_offset(el, 918, 13)
action.click()
action.perform()

Even the action chains not performed well and kept throw the same issue.
After the long dig into the problem and found the stable solution.

Solution

The error says that , Another element is covering the element you are trying to click. So we could use execute_script() function to execute the click event.
The solution is
1
2
element = driver.find_element_by_class_name('pagination-next')
driver.execute_script("arguments[0].click();", element)

The execute_script() method has 2 parameters. The first is the script, the second is a vararg in which you can place any parameters used in the script.
In this case we only need the element as parameter, but since it is a vararg our element is the first in the collection. For example you could also do driver.execute_script("arguments[0].click(); arguments[1].click();" element1, element2) This would click both elements passed

I hope this will help many of us.




Comments

  1. If you're looking to lose fat then you certainly need to jump on this brand new custom keto plan.

    To create this service, licensed nutritionists, personal trainers, and chefs have united to provide keto meal plans that are powerful, decent, money-efficient, and delicious.

    Since their launch in early 2019, 100's of clients have already remodeled their figure and well-being with the benefits a professional keto plan can give.

    Speaking of benefits: clicking this link, you'll discover 8 scientifically-proven ones given by the keto plan.

    ReplyDelete
  2. thanks for sharing..

    ReplyDelete
  3. thanks, javascript help alot :)

    ReplyDelete
  4. Superb blog post! And this blog clearly explain about for useful information. I would Thanks for sharing this wonderful content. Its very useful to us. Keep it up!
    php interview questions and answers
    php interview questions for freshers
    php interview questions for experienced
    php basic interview questions
    core php interview questions

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. CopyCat is a great Figma Plugin Development tool to quickly get started with development. It's simple to use and install, and it comes with a wide range of features that make developing for Figma much easier.

    ReplyDelete

Post a Comment

Popular posts from this blog

Pyhton auto post to blogger using Google blogger API

Connect VPN via Python

Salesforce Missing Organization Feature: CommonPortal null