Protractor: Navigating Pages Without Angular

Aug 8, 2015

compassI'm currently using Protractor to build e2e test automation for my team. And while Protractor is especially helpful for Angular applications, my app is non-angular. This has presented some challenges... and because of it's asynchronous nature, some truly maddening challenges at that :)

Case in point: page loads.

Because I don't have Angular telling Protractor when a page has finished loading, I need to handle it myself. Thus I stole some ideas from my work with Geb, namely, the to() and at() methods. These two methods navigate to, wait for, and verify all page changes. Here's how it works...

First, in my basePage (that is extended from all other pages), we have two friendly methods: = function() {
    var that = this;
    return browser.wait(function() {
        // call the page's pageLoaded method
        return that.pageLoaded();
    }, 5000);
}; = function() {
    browser.get(this.url, 5000);
    // wait and verify we're on the expected page

These methods rely on each page having the properties url and pageLoaded. For example, the page object could include:

var QsHomePage = function() { this.url = ''; // pageLoaded uses Expected Conditions `and()`, that allows us to use // any number of functions to wait for, and test we're on a given page this.pageLoaded = this.and( this.hasText($(''), 'Quality Shepherd') ); ...

The url property is just a string. It can be fully qualified, or relative (which then gets appended to the baseUrl). The pageLoaded property uses Protractor's [Expected Conditions]( and() method, that allows you to use any number of functions to both wait for the page, and test that we're on the correct page.

In this example, I only need one EC function, hasText, but you can add as many as necessary, separated by commas (eg. you could wait for a spinner to NOT be displayed, for a header to be displayed, AND check the page title). Each function need only return true.

Finally, we can call these in our specs thusly:

describe('Quality Shepherd blog', function() { beforeEach(function() {; });

it('home link should navigate home', function() {;


In the beforeEach block, we call, which calls both the to() method to navigate to the page, and the at() method to wait/verify the page.

Then in the spec, we click on the home page link, and use at() inside an expect() to verify we're on the right page. We can do this because we return the result of the Expected Conditions. If all are true, the test passes; if even one returns false, the test fails.

The result is a clean way to navigate pages without Angular.

I use this in my protractor_example code up on the GitHub...

Charter Communications Sucks

Jun 12, 2015

dinosaurMy current ISP is Charter, and yes, like all of their brethren, they suck.

For the past four years I've signed up for their two year, $40/mo, internet-only program, which they DO NOT ADVERTISE, but will begrudgingly give you if you call and cmplain enough. Well two months ago this ran out. I called to sign up for another two years... only to find out they now REALLY, REALLY don't offer it anymore. So after three calls, I eventually believed them... for reals. Hardball. Fine.

They raised my rate to $67 a month.... ouch.

So I paid the first month and looked around at ANY other provider. But, as they know, there are no alternatives that don't also suck ass. Lame.

So I got my second bill from them today and decided... fuck them. I called and told them I wanted to cancel, and that it was because of the price. They then offered me another year @ $40/mo.

Clearly I wasn't complaining enough!

This is less than ideal customer service... and yet it seems to have become an industry norm. And while 1/3rd of Charter's business (internet), is killing the other 2/3rds (phone/tv), at least this gives them a step up on car salesmen and realtors for "most annoyingly tolerated, unnecessary, service providers on the planet" award. For now.

Anyway, I won't say "problem solved", but I'm willing to celebrate "problem temporarily averted". I look forward to the day when some Google-sized meteor finally kills off these dinosaurs.

Google Calendar Event List Javascript Script

May 26, 2015

13A reasonable amount of moons ago, Google shut down support for their Google Calendar API V2. Understandable, except I was using a script on a few sites to pull down calendar events! Fine... so I suffered like the rest of the huddled masses, and was forced to embed the fuggly Google Calendar on my sites, while waiting for someone to spend the time to update the script to use the new version of the API.

It didn't happen.

Months went by... and no updated script. I finally got tired of looking at it, so today I spent a couple hours learning how the API worked, and cobbled together a little javascript script that pulls down my duet's gcal events, and displays them on our website.

I've shared the code up on GitHub. It simply grabs future events (via an async call), from a public Google Calendar, and inserts them into a div on a webpage. No authentication needed, and it should be easy to refactor to include any data you want.

Hope it helps someone...

Millennials: The Missing Manual

May 12, 2015

Obviously I've been too busy to post anything for some time... but a colleague just shared this and I wanted to pass on the funnies.

Inspirado: Steve Jobs

Mar 15, 2015

I would join Apple Computer about two years after this clip, and there was still grumbling about OpenDoc's demise; one of the many technologies that geeks dug, that Jobs killed. Obviously history has been kind to his decisions, but at the time, these decisions took serious balls. Jobs was many things... but lacking cojones? I seriously doubt anyone ever accused him of that.

Can You Give Me A Login?

Feb 12, 2015

P1000811-1QA folk are protective of their logins, and rightly so. We create users to test with, and expect their accounts to be in the state we left them in. It's not convenience... it's essential.

But Devs will ask you for a login to this server, or that server. So send them the link to the wiki page that describes how they can create their own logins, and even walk them through it if need be.

But if they still come asking for a login, try creating, and sending them a login with the username "lazydevs". Problem solved :)

Sometimes the passive-aggressive solution is the right solution.

Top 10 Automation Blogs of 2014

Feb 7, 2015

b0aff6c0-2995-012f-b150-0050569439b1 I am VERY surprised to learn that I made the top 10 in TestBuffet's top 21 automation blogs of 2014! It's especially nice to be listed among some of the blogs I read... not to mention discovering some new blogs I have yet to read. Very nice, indeed.