AMA: Protractor for e2e Testing?

John X asks…

 I have dodged the AngularJS /Protractor bullet for many years now. May last foray, some 5 years ago, was a cluster to put it mildly! Cucumberjs/Angularjs/Protractor/chai/mocha/ the stack was in its infancy and failed miserably!! Many cycles were spent pulling fixes from our own repos instead of waiting for PRs to get done. This was in stark contrast to the ease and stability of the automation I wrote using Watir-Webdriver and eventually Watir.

I am now faced with automating the regression test cases for an Angularjs App.

Question: Do I finally jump back into the using stack that almost caused me to lose my mind, or is it possible to use Watir/Selenium to build out meaningful e2e UI automation for an angularjs app as we dawn on 2019?

My response…

It’s still my opinion in 2018 that writing e2e tests in Node using either Protractor or WebDriverJs is still more difficult than using Watir in Ruby.

Sure using async functions with await commands makes things easier than before (see examples in our project), when you would have first come across Protractor, but I still feel like there’s a lot of catching up to do to get to the stability and ease-of-use of Watir.

My decision would come down to whether others on your project are going to be comfortable maintaining tests in ruby – if they are I’d use Ruby and Watir, otherwise I’d revisit Protractor if they really want to use Node.

Testbash Australia 2018

I only speak at one conference a year and this year that conference will be the first ever Australian Testbash in Sydney on October 19, 2018:

TestBash_Australia_2018_Adverts_DOJO_EVENT_BANNER.png

My talk:

At WordPress.com we constantly deliver changes to our millions of customers – in the past month alone we released our React web client 563 times; over 18 releases every day. We don’t conduct any manual regression testing, and we only employ 5 software testers in a company of ~680 people with ~230 developers across . So, how do we ensure our customers get a consistently great user experience with all this rapid change?

Our automated end-to-end (e2e) tests give us confidence to release small frequent changes constantly to all our different applications and platforms knowing that our customers can continue to use our products to achieve their desires.

Alister will share how these automated tests are written and work, some of the benefits and challenges we’ve seen in implementing these tests, and what we have planned for future iterations.

Takeaways: How to effectively use automated end-to-end testing to ensure a consistent user experience in high frequency delivery environments

Grab a ticket before they sell out #

AMA: JavaScript in Test Automation

Max asks…

First of all thanks for sharing all your insights on this blog. I regularly try to come back to your blog and I helped me grow as a QA Engineer quite a lot.
I wanted to ask you on your opinion on a seemingly new generation of test tools for the web that are written in JavaScript to help deal with all the asynchronicity on modern front end frameworks. Our company is in the process of redesigning our website and it seems that it just gets harder and harder to deal with all the JavaScript in test automation. I recently started looking into some other tool like cypress.io, but as of now they still seem quite immature.
Could you help me and point me in the right direction?

My response…

I think there’s two parts to the JavaScript asynchronicity issue which are not necessarily related.

Modern JavaScript front-end web frameworks (like React and Angular) are designed to be asynchronous and fast and therefore this can cause issues when trying to write automated tests against them. I don’t believe writing automated tests in an asynchronous way actually makes the tests easier to write, or more maintainable or robust, but just a result of writing these tests in the same way the web frameworks work.

You can write synchronous tests (like using Watir/Ruby) against asynchronous web interfaces, you just need to use the waiting/polling mechanisms (or write/extend your own) – the same as you need to do in asynchronous test automation tools.

We choose WebDriverJS for automated end-to-end testing of our React application as it was the official WebDriver for JavaScript project and seems to be a good choice at the time. I somewhat regret that decision now as using a synchronous third party implementation like webdriver.io seems like an easier way to write and maintain tests.

I have tried to use cypress.io but the way it controls sites (through proxies) has (current) limitations like not working on iFrames and cross-domains which are deal-breakers for our end-to-end testing needs at present.

If you don’t need to write your end-to-end tests in JavaScript I’d say avoid it unless absolutely necessary and stick to another non-asynchronous programming language.

I’m glad I’ve been able to help you grow over the years.

AMA: hiding/changing IP addresses using Watir

Mudit Bhardwaj asks…

Hey! In order to test the security of a website, I’m trying to create hundreds of accounts. However, after a certain limit, there is always an error which prevents me from going further.
How can I hide/change my ip address during each iteration with watir?

My response…

I can understand why there would be this limitation in place as this activity seems suspicious from a systems perspective.

Watir can’t change the IP address. You can use an anonymous browser profile and/or delete cookies for different account creation runs but this probably won’t help.

I’d speak to your development/devops/systems team to whitelist your IP address(es) you are using for this purpose.

Puppeteer for Automated e2e Chrome Testing in Node

I recently noticed the new Google Chrome project Puppeteer:

Puppeteer is a Node library which provides a high-level API to control headless Chrome or Chromium over the DevTools Protocol. It can also be configured to use full (non-headless) Chrome or Chromium.

As someone who only runs WebDriver tests in Google Chrome anyway, this looks like a promising project that bypasses WebDriver to have full programmatic control of Google Chrome including for automated end-to-end (e2e) tests.

The thing I really love about this is no Chromedriver dependency and how installing the library installs Chromium by default which can be controlled headlessly with zero config or any other dependencies.

You can even develop scripts using this playground.

I set up a (very basic) demo project that uses Mocha + Puppeteer and it runs on CircleCI with zero config. Awesome.

Five Books I Enjoyed in 2017

Happy New Year! 🎉 One thing I love about the end of the year is going through all the lists I have made during the year and counting up my stats and reflecting on things. I read (to completion) 37 books (and abandoned a further 4) in 2017. Not quite as many as 2016 when I finished 48 books but I had some difficult circumstances with family illness in 2017.

Here’s five of my favourite books I read in 2017 (with Good Reads links):

9781471138867_hrThe Art of Stillness: Adventures in Going Nowhere by Pico Iyer. This was the first TED book I read and having read quite a few more since it was probably my favourite.  I read this at a part of the year where I was over-committing to too many things (travel, conferences, events) and it was a apt reminder to slow down and appreciate things. This book led me to my mindfulness meditation practice which I took up in the later part of the year (and have continued to do since then).

how-to-fail-at-almost-everything-and-still-win-big-coverHow to Fail at Almost Everything and Still Win Big: Kind of the Story of My Life by Scott Adams. I’m not a huge fan of Dilbert, but I’m a big Scott Adams fan after reading this book. The ideas I really like are the importance of systems over goals (a good blog post about that here), and that passion follows success (passion doesn’t lead to success: you can be passionate about something and really suck at it). Also the importance of diversification. An enjoyable well written read.

29430779._SR1200,630_Payoff: The Hidden Logic That Shapes Our Motivations by Dan Ariely. The second TED book I read this year (I love the format!) and the best book about motivation I’ve read so far. I’ve tried to read Drive by Dan Pink a few times but haven’t been motivated to finish it. The thing I learnt from this book is that we lose meaning and motivation in life by outsourcing the hard work/small things (like cleaning, gardening, maintenance) – we accomplish more but get less.

subtle-art-coverThe Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life by Mark Manson. This book is a bit weird. It’s hard to read, because it jumps all over the place, but there’s so much good content it’s still worth reading. I also wish the book had a really clear list of things I could take away from the book and do, rather than understanding the general message which is a bit bleak. Still a good book and enjoyable read after all that.

27985224Deep Work: Rules for Focused Success in a Distracted World by Cal Newport. One of the last books I read this year it is particularly relevant to me working for a 100% distributed company in an asynchronous communication environment it’s easy to get distracted by constant chatter and noise and not focus enough on deep work. The thing about this book is that if you can master deep work in our current world it’s another skill that you can use to be very successful as it’s a huge competitive advantage.

*** BONUS ***

9781760630775Not work related but I read a lot of fiction particularly thrillers. Michael Connelly’s latest Harry Bosch book Two Kinds of Truth was just fantastic: hard to describe how good it was.

 

 

 

AMA: Clicking a non-visible element in Watir

Mike asks…

Is there any way to make Watir click a link/button that is not visible? I wanted to switch from Capybara/CapybaraWebKit (which allows clicking non-visible elements) but I am stuck since Watir always times out on the click attempt.

My response…

The easiest way to do this is just to execute a click in JavaScript on the object itself.

In Watir, this looks something like:

browser.execute_script( "return arguments[0].click();", browser.link(:id => 'blah')

Hope this helps!