Browser Testing with Python !
AbdealiJK (~AbdealiJK) |
1
Description:
Over the past 10 years, I have written many many scripts which have had to interact with browsers.
But browsers … sighs … they are one of the most complex and painful programs that have been created. They have been designed for humans, and automating a task with them is an uphill battle.
I have faced all kinds of issues I would have never expected:
- It is impossible for a computer to know when a page has "loaded"
- It is impossible for a computer to know when a click event has "completed"
and the most common answer to all of these is "Hey, add a timeout to wait for it" - which is an absolutely terrible solution. Way too many times - I have found that I cannot run a browser automation script if my laptop is running on battery (Because all the page loads have become too slow for the timeout!)
I believe that writing code should be fun (One of the main reasons I enjoy python). And browser automation is not fun.
Over time, I have tried multiple frameworks for these tasks. With loads of attempts with selenium, webdriver, cypress, etc. and even hacky approaches like AutoIt, recorders, karma, etc. I finally stumbled upon the combination of playwright + python which has worked phenomenally well for us.
I'd like to discuss this case study as I am sure this is a problem many people in the world must be facing. I have seen many discussions about the issues E2E testing poses - but never a "solution" to them, which is what I'd like to discuss.
Prerequisites:
- Some experience with building web applications
- Some experience with testing web applications
Content URLs:
I had given this talk at PyDelhi 2023 You can find the slides at: Gooole Slides
Speaker Info:
Hi, I'm Abdeali Kothari - a.k.a Ali (if we're talking) or @AbdealiLoKo (if we're typing)
I graduated from IIT Madras in 2016 and then worked with American Express, followed by Corridor Platforms where I am architecting a Decisioning platform for analytics in the Financial domain.
I've dabbled with Robotics, Operating System architectures, Machine Learning, Game Development, and Web Development a lot for a bunch of personal projects.
And worked mainly in Big Data, Machine Learning, and Analytics in the Financial Domain for enterprise-productional use-cases.
I'm a big fan of code hygiene and clean architecture. With a lot of Code Analytics experience under my belt.
And worked mainly in Python in all the above fields for about 13 years now (Back when the first blogpost telling us to stop using Python 2.x was written :D)
I'm extremely lazy - and hence an automation freak. And have created great automated test suites and CI/CD pipelines to help me remain lazy.