
DATA SCIENCE
ASHISH AMAR | February 16, 2022
Well, if you’re a beginner to automation in Python and you want to setup the development environment for working with Selenium, the first step is to download the webdriver that matches the version of your browser.
Now, some developers suggest you download a web driver and turn off the automatic updates for the Edge browser. If you do that, you might miss out on the new features of the browser. If you want to keep the updates on, then you will have to navigate to the page where you download web drivers and search for the appropriate version and download it each time a new update is released.
This is where the tool comes in. It automatically fetches the browser version using a small batch file and also fetches the PC architecture and downloads the appropriate version required for your architecture. So, the next time you want to download an updated web driver, you don’t have to search for the driver that matches your browser version. You just have to run this tool and it will be downloaded automatically. Please note that this code downloads the driver for the Edge browser only, but it can be modified for the browser of your choice.
Feel free to check out this code, download it, and use it.
[Here’s a link to the code]
• A link to the demo video is also available, [here]
Here are a few things you will have to do before running this code →
• Add the path of the edge executable (msedge.exe) to the system path.
• Make sure that the path to the edge executable in the batch file matches the path on your system. (You should do this only if you have changed the installation path of the edge.)
• Make sure that the batch file is present in the same folder as the code.
Good Luck!
Read More
THEORY AND STRATEGIES
ASHISH AMAR | February 16, 2022
We had to make a project presentation in which we (as in me and my friend) had to conduct an additional survey to back up our point.
Now, like any other student, we waited till the deadline. Well, to be fair, we didn’t have a choice. We had a lot of work from college. But that’s the story of any student, I guess.
A snap of the form which was used to collect the information
So, we sent the link and got back a few responses. But, since the deadline was the next day and the survey had to be on a larger scale, I decided to create a bot for it. (Because that’s the obvious answer for everything. [Pun intended]).
Here it is:
• Link to the Code.
A few things which I learnt are that while using the click() method, if we’re using xpath, it’s not easy for the web driver to locate a clickable element if it’s embedded under div tags and span tags. It throws a “no such element exception”. The best thing to do would be:
• Use the label of the element you want to locate on the form.
• To use the pre-filled links feature of Google forms. (Basically a pre-filled link, which uses parameters to fill the form). Best suited for small forms.
Read More
ASHISH AMAR | February 11, 2022
Udemy is a great place to learn whatever you want. You can enroll in a few free courses as well as a few paid ones. There are tons of sites that offer the paid ones for free. How these sites work is that the instructors give the students a limited time frame and a coupon that enables them to get the course for free. So I built a small bot which would enroll in those free courses (as I was bored and just wrote some random code).
That turned out to be a mistake, as after a few days, there were a few hundred courses in my account. Now I thought, “ok, I could just filter those enrolled courses by rating and maybe check out a few top-rated courses.” But then I saw that Udemy offers only a filter by “title,” “instructor name” and so on. But not filtered by rating.
A random snippet of the source code of the bot.
Then I thought about it why not create a bot which filters the ratings and fetches me its links? Since I made a bot to collect courses, why not build one for filtering as well? Ideally this is what I did (cuz I was “jobless” and I wish I could’ve coded something useful then.
Anyway, here it is.
• Link to the Code.
• Link to the Demo Video
Challenges Faced while building this and how I solved them.
• Implicit wait() and explicit wait() make the driver wait for a specified number of seconds for some element to load, but do not delay the driver for that many seconds. The selenium driver would give a "NoSuchElementException" . This was solved by using time.sleep()
• 2 functions calling self.driver in the same class created 2 different driver instances, rather than linking them. (As suggested by a few posts on stack overflow). This was solved by creating a base class which initializes the driver and inherits from that class.
Read More