A simple fix to the “Element is not clickable…” problem in Selenium
Not guaranteed to work all the time but hey it worked for me so I’m just sharing
A while ago, I was intrigued by the IBD 50 - a list of the top 50 stocks that have been screened by the CAN SLIM method and distributed by Investors’ Business Daily (IBD).
You would typically have to subscribe to the IBD in order to get access to the list but in 2015, innovator ETFs released an ETF (ticker: FFTY) that tracked the IBD50! And since the holdings of the ETF are available publicly, we can just extract the holdings of FFTY in order to know each week what holdings are recommended by the CAN SLIM method.
However, as I tried to extract the holdings data from zacks.com, I faced an issue in Selenium. And in this article, I describe the quick fix!
p.s. I won’t be describing exactly how I extracted the info here but if you’re interested, the full code can be found here
Loading the webpage with Selenium
Because I was lazy and did not want to add the geckodriver to PATH (which you can find how to do here), I needed to specify my executable_path. ( ps: the R in front is for Python to read it as a raw string and hence ignore the slash)
Once that was done, I simply set the URL for the FFTY holdings and used the driver to open the webpage.
Accessing a Dropdown box
And here’s where the problem started… I needed to access the dropdown list and change it such that it would show all 50 entries. The issue here was that I kept getting an error that the element (the dropdown box) was blocked and not clickable! It turns out that the “Accept Cookies” form covered the dropdown box when the page initially loaded.
This was easily solved by using
window.scroll to scroll it down about 400p (out of a typical window size of 1080p) so that the cookies form was out of the way! With that done, I simply had to find the dropdown box element and select '50'
So there you have it! Super easy fix. Looking at other descriptions of this problem here, I think this fix should theoretically work for most of these “element is not clickable” issue since these typically arise because some page element is blocking the element you’re trying to access. So just scroll down away from it, and your element should be easily clicked!
Originally published at https://nosparechange.com/a-free-list-of-computer-generated-market-growth-stocks/