I wasn't too excited when I was informed that the web app I had been automating with Selenium was about to undergo a major UI overhaul. While UI changes meant improved functionality and user experience, they also meant hours of rewriting and debugging automating scripts. My existing Selenium framework had served me well, but this change felt like an opportunity to explore newer tools. That’s when I decided to give Playwright a try.
Switching from Selenium to Playwright wasn’t a decision I made lightly. Selenium had been my trusted companion for years, and I was comfortable with its quirks and limitations. However, the thought of tackling flaky tests and struggling with timing issues during the migration process pushed me to consider Playwright. Its promise of faster execution, better handling of modern web applications, and built-in features like auto-waiting felt like the answer to my prayers.
Selenium does provide wait functionality when web app elements are dynamically being generated and not visible or clickable right away. However, this has always been a difficult debugging process to get things just right and not expect errors from time to time. While my existing automating tools with Selenium get the job done, there are times when they stop due to some errors. Now, this cases are rare, but to happen. This was another reason I wanted to see if other frameworks could handle such events better.
The transition began with a sense of curiosity. Installing Playwright was straightforward with a simple pip install. It didn't require separate WebDriver setups like earlier versions of Selenium did. Latest versions of Selenium are also not too difficult to get started with. Playwright offered a single API that supported Chromium, Firefox, and WebKit right out of the box. The simplicity of getting started gave me the confidence to dive right into rewriting my scripts.
The first script I rewrote was for logging into the application. To my surprise the process went super easy and fast, as UI changes didn't really affect the login page. However, I still needed to rewrite the code in Playwright. Getting Playwright going and its methods seemed a lot easier to work with and often self-explanatory. My login script executed flawlessly on the first attempt. It was a small victory but one that made me eager to keep going. There was one problem. Initially I started with using Chromium, but started having issue right away. I had to switch to Chrome, since I use Chrome most often and most of my scripts did run on Chrome. Once I made this small change everything worked great. I am sure I could figure out the issue with Chromium. But at this time, that is not an issue. I am happy using Chrome.
Normally, when I find a new framework to work with I go through documentation, read various tutorial and watch videos on the topic. However, this time I didn't have too much time and wanted to jump in and get things done. I enlisted ChatGPT to assist. This made the flow go even faster, especially when it came to debugging and figuring out various errors when running the script. Although ChatGPT is great helping with code, it can't really write full script for specific needs. It does try and pretends to. In my experience I haven't seen a fully functioning code from ChatGPT for specific tasks. However, it is great helping finding solutions. And I didn't mind figuring things out on my own and writing the code from scratch. Without fully understanding what each line does, it wouldn't be possible to complete any of the scripts. As scripts are connected with each other in a larger scale.
I am impressed how easy it was to use Playwright. I was able to improve on the code with less lines of code and even found solutions for the previous problems I had. I believe I was able to eliminate the rare case errors as well. That is a huge success.
One of the more complex tasks was rewriting scripts that required multiple browser contexts. My Selenium scripts didn't really involve working with multiple browser contexts and tabs. This new UI changes created multiple tab openings when in the past all actions would happen within the same tab. Playwright’s ability to handle multiple contexts within a single run simplified this significantly. The approach Playwright takes compared to Selenium is different, at first I wasn't sure why it was doing it. However, as I completed the script it made more sense and made the flow go smooth. I tried multiple context with Selenium as well, just out of curiosity, if I were to repurpose the old code. Selenium's approach while different, wasn't too difficult either.
One of the interesting things I discovered was how Playwright wouldn't automatically download files when clicking a download button. Normally, if human interacts with the browser and there is a download button, after clicking the file downloads to the standard folder. Playwright didn't do that automatically. It wanted to make sure the download information is obtained properly and saved programmatically. It did work without any issues, and in fact worked better because script managed file naming, destination, etc. It was clear what was happening.
Reflecting on the experience, I realized that migrating to Playwright wasn’t just about adopting a new tool. It was about embracing a mindset of continuous improvement and adapting to change. The transition taught me the value of exploring modern technologies and being open to reevaluating established practices. The journey wasn’t always smooth, but the end result was worth the effort. My new Playwright scripts were faster, more reliable, and easier to maintain. More importantly, they aligned better with the evolving needs of the application I was testing. It felt like I had future-proofed my automation strategy.
Looking back, I wouldn’t hesitate to make the switch again. Playwright has not only streamlined my automation processes but also renewed my enthusiasm for automation. If you’re facing a similar situation, whether it’s a UI overhaul or persistent issues with Selenium, I highly recommend giving Playwright a shot. You might just find yourself wondering why you didn’t switch sooner. Ultimately, what began as a necessity turned into an opportunity for growth. The experience reinforced my belief that staying adaptable and open to new tools is important for improvements. The transition to Playwright wasn’t just about rewriting code—it was about rewriting the way I approached coding and automating tasks.
#playwright is super awesome and has a nicely handling. Sometimes I use it to fill out forms at work - not really what is intended for but - yeah it's a tool^^
!BBH !LOLZ !MEME !PIZZA
Credit: orionvk
Earn Crypto for your Memes @ HiveMe.me!
lolztoken.com
You look drunk!
Credit: hollowknightgod
@geekgirl, I sent you an $LOLZ on behalf of master-lamps
(1/10)
Delegate Hive Tokens to Farm $LOLZ and earn 110% Rewards. Learn more.
lolztoken.com
Thank you for being an !LOLZ supporter.
I was wondering from the title what those things were, like selenium the mineral and I was like uh? 🤣 Now I understand, but it's python I'm not expert on that field
Even in the coding world, things are evolving. Happy to know you've adapted :)
Last time see that Playwright framework becomes more popular even on medium and stackoverflow more posts and questions appeared there.
These are good tools for coding. Its so complicated !
Things change over time, and I agree that sometimes you need to change. If things aren't working out, then try to find a solution. Things don't always work, but I am glad that you got things to work out.
!bbh !hiqvote
I didn't know that ChatGPT also helps for coding.
😎👍🏾 @tipu curate
Upvoted 👌 (Mana: 12/52) Liquid rewards.
@geekgirl! @master-lamps likes your content! so I just sent 1 BBH to your account on behalf of @master-lamps. (2/20)
(html comment removed: )
$PIZZA slices delivered:
@danzocal(3/10) tipped @geekgirl
master-lamps tipped geekgirl
The rewards earned on this comment will go directly to the people( @davideownzall ) sharing the post on Reddit as long as they are registered with @poshtoken. Sign up at https://hiveposh.com. Otherwise, rewards go to the author of the blog post.
@trumpman, the HiQ Smart Bot has recognized your request (2/3) and will start the voting trail.
In addition, @geekgirl gets !PIZZA from @hiq.redaktion.
For further questions, check out https://hiq-hive.com or join our Discord. And don't forget to vote HiQs fucking Witness! 😻
!PIZZA