DEV Community

Phil
Phil

Posted on

Let's ask ChatGPT about Playwright versus Ruby's Capybara

I wanted to learn more about Playwright, so I simply asked ChatGPT a series of questions to find out more! See some of the below snapshots for my interesting conversation with the AI bot that is all the rage nowadays.

ChatGPT writes a Playwright test
Wow! ChatGPT puts together what looks to be a valid UI test for a Google Search.

Asking about await
I have pretty basic knowledge of async and promises, but I wasn't super clear on why it might be so prevalent in JS-based UI testing. Maybe I've always oversimplified my take on the complexity of DOM events. Returning a promise object on a mouse click is a little foreign to me.

First attempt at refactor
I have a tendency for code to simply look cleaner. For example I'll always try to refactor away string literals where I can. I thought maybe the await keyword can be abstracted away somehow.

Second attempt at refactor
I still wasn't too satisfied so I asked ChatGPT to refactor again.

ChatGPT writes a test in Capybara
I went ahead and asked ChatGPT to write the same test using Capybara. It produces exactly what I expect (and with MUCH fewer lines of code!)

ChatGPT gives a take on the two frameworks
And finally I ask for ChatGPT's take on what I perceived as a vast difference... verbosity?

So there you have it! A quick exercise and comparison between Ruby's stack and Playwright, and an interesting assessment on both from ChatGPT.

Top comments (0)