Email Subscription Form

Saturday, February 15, 2020

Why I'll Be Using Cypress For UI Automation

I've mentioned in previous posts that I don't do much UI automation.  This is because the team projects I am currently on have almost no UI, and it's also because I'm a strong believer that we should automate as much as we can at the API level.  But I had an experience recently that got me excited about UI testing again!

I was working on a side project, and I needed to do a little UI automation to test it out.  I knew I didn't want to use Selenium Webdriver, because every time I go to use Webdriver I have so much trouble getting a project going.  Here's a perfect example: just one year ago, I wrote a tutorial, complete with its own GitHub repo, designed to help people get up and running with Webdriver really quickly.  And it doesn't work any more.  When I try to run it, I get an error message about having the wrong version of Chrome.  And that is why I hate Webdriver: it always seems like I have to resolve driver and browser mismatches whenever I want to do anything.

So instead of fighting with Webdriver, I decided to try Cypress.  I had heard good things about it from people at my company, so I thought I'd try it for myself.  First I went to the installation page.  I followed the directions to install Cypress with npm, and in a matter of seconds it was installed.  Then I started Cypress with the npx cypress open command, and not only did it start right up, I also got a welcome screen that told me that there were a whole bunch of example tests installed that I could try out!  And it automatically detected what my browser was, and set the tests to run on that version!  When I clicked on the Run All Tests button, it started running through all the example tests.  Amazing!  In less than five minutes, I had automated tests running.  No more Chrome version must be between 71 and 75 messages for me!

The difference between Cypress and Webdriver is that Cypress runs directly in the browser, as opposed to communicating with the browser.  So there is never a browser-driver mismatch; if you want to run your tests in Firefox, just type npx cypress run --browser firefox, and it will open up Firefox and start running the tests.  It's that easy!  In comparison, think about the last time you set up a new Webdriver project, and how long it took to find the Firefox driver you needed, install it in the right place, make sure you had the PATH configured, and reference it in your test script.

Here are some other great features of Cypress:

  • There's a great tutorial that walks you through how to write simple tests.
  • Every test step has a screenshot associated with it, so you can scroll back in time to see what the browser looked like at each step.
  • Whenever you make a change to your test and save, the test automatically runs in the browser.  You don't need to go back to the command line and rerun a command.
  • You don't have to act like a user.  For example, you can make a simple HTTP request to get an authentication token instead of automating the typing of the username and password in the login fields.  
  • You can stub out methods.  If you wanted to test what happens when a certain request returned an error, you can create a stub method that always returns an error and call that instead of the real method.
  • You can mock HTTP requests.  You can set an HTTP request to return a 404 and see what that response looks like.
  • You can spy on a function to see how many times it was called and what values it was called with.
  • You can manipulate time using the Clock method- for example, you can set it to simulate that a long period of time has elapsed in order to test things like authentication timeouts.
  • You can run tests in parallel (although not on the same browser), and you can run tests in a Continuous Integration environment.

In addition, the Cypress documentation is so clear!  As I was investigating Cypress, it was so easy to find what I was looking for.  

If you are tired of fighting with Webdriver and are looking for an alternative, I highly recommend that you try Cypress.  In less than ten minutes, you can have a simple automated test up and running, and that's a small investment of time that can reap big rewards!


  1. Cypress is an amazing tool and their documentation is one of the best I've seen!

  2. I like it as well. About parallelization, I’ve used CI to spin up containers in parallel, and there are npms to aggregate their reports

    1. can you please elaborate hiw you achieved it.Better if you can create a post and provide a link. thanks

  3. Hi, Kristin! I've started learning test automation recently with Capybara (which is a Selenium and Ruby framework as far as I'm concerned) and I have already faced some of the problems you listed.
    Would you recommend newbies learning Cypress first instead of Selenium?

    1. Hi Claudio! I can't say definitively, since I only have about an hour of experience with Cypress so far. But so far it looks like a much better starting point for people who are new to UI automation.

  4. This comment has been removed by the author.

  5. I've also started using Cypress and have had a great experience so far. The documentation is really good. Also, I love the built-in support for making http requests from within tests. Makes simplifying workflows like Logins very easy.

    1. I'm looking forward to trying out the http request functionality in Cypress, and it will be the subject of a future blog post!

  6. Thanx a lot! Can't wait for next post about Cypress exploration

  7. I'm glad you liked this post, Valeriya! You can read my latest post on Cypress here:

  8. Hey Kristin,

    No doubt Cypress installation is awesome and pretty straight forward, however, it has some potential flaws as well . Well , every tools has so no big deal. However , my deep dive reveals certain serious limitations such as

    1. No Support for Trusted Actions ( mouseover- drag drop etc)
    2. Can’t handle multiple tabs and windows
    3. If your website is responsive , then support is limited to emulation by changing view port. No mobile web

    4. When I was automating automation , in user registration, found error which says DOM changed and Cypress was failed to click.This is similar to StaleElement but could not find any resolution yet
    5. No Safari Support
    6. Not sure how to run in remote machines like GRID
    7. It can’t open sites such as or its a known issue in GITHUB
    8. Pls try opening in cypress and you will understand its architecture flaw

  9. Very useful post and I think it is rather easy to see from the other comments as well that this post is well written and useful. I bookmarked this blog a while ago because of the useful content and I am never being disappointed. Keep up the good work..
    software testing company
    QA Outsourcing Sevices

  10. Hey Guys !

    USA Fresh & Verified SSN Leads with DL Number AVAILABLE with 99.9% connectivity
    All Leads have genuine & valid information

    First Name | Last Name | SSN | Dob | DL Number | Address | City | State | Zip | Phone Number | Account Number | Bank Name | Employee Details | IP Address

    *Price for SSN lead $2
    *You can ask for sample before any deal
    *If anyone buy in bulk, we can negotiate
    *Sampling is just for serious buyers

    ->$5 PER EACH

    ->Hope for the long term deal
    ->Interested buyers will be welcome

    **Contact 24/7**
    Whatsapp > +923172721122
    Email >
    Telegram > @leadsupplier
    ICQ > 752822040

  11. Are you interested in trading bitcoin binary and forex trade where you can earn 100% of your investment daily If you invest as low as $200 you will get a profit of $2,000 after 72 hours if you are intrested you can contact him via email: +12132951376(WHATSAPP)

  12. I think Cypress will be great for UI animation. I am sure that most people who follow the link, and use Cypress for animation will agree with me here. This software is perfect for animation, and I've done a lot of cool animation stuff using this software.


New Blog Location!

I've moved!  I've really enjoyed using Blogger for my blog, but it didn't integrate with my website in the way I wanted.  So I&#...