Combining locators in protractor

I’d like to start with the following service announcement,

you really shouldn’t need this.

That being said; I’ve started using a third party component library which led to a use-case for this.

It so happened that i was creating a page object for a component library called ag-grid. At first glance i thought nothing special about it; and that i could retrieve rows normally. ag-grid however supports the pinning of columns to the left and/or right side of the list. And these rows then fall inside their own respective markups.

Now you can easily create a structure allowing me to target the (non-)pinned columns. But for ease of use being able to get full set of cells can also be useful and might be more suited for the test case.

This led to the creation of the following code.

As you can see it returns a new ElementArrayFinder which is the return type for the all locator and thus what we need for the aggregate.

In order to create the aggregate response it resolves each locator’s getWebElements response through Promise.all. It then fulfils the deferredAggregate with the promised results reduced to a single WebElement array.

In this implementation the combinedLocator.toString is also supplied. This is to ensure that feedback for this aggregation also contains all locators in the message. For the creation of the ElementArrayFinder itself it is not required though

Unit testing an AngularJS directive’s private functions.

As we all know Javascript gives us the awesome ability to create functions inside functions. This allows us to create private functions which support the main function. It is also something we do often when creating object functions. This structure is used by angular for the creation of providers and directives alike.

Every once in a while I personally come to a point where I would like to test these private functions. This is especially true for use cases in Angular such as directives. Continue reading

Web-components like AngularJS directives

As you may already know web components consist out of a set of technologies which are combined to create a custom element for use in your HTML markup. The main additions, as described in several blogposts, are HTML imports, Shadow Dom and Templates combined with isolated scripts and styling. (If these concepts are new to you i suggest you read up on web components at

This blog post has a living example on

Continue reading

Javascript oneliners: functions are attributes too

Just a small reminder. Javascript allows you to call methods based on their name. So if a DOM element has a addClass and removeClass which both take the same argument we could write:

but we could also write

Sometimes this means you can use this technique to write powerful one liners.

Creating a superelipse with canvas

Today a colleague asked a group of front-end developers how he would create a superelipse.

A superelipse

His current solution was to use a svg mask to remove all non essential visual information. This solution however had a setback, because we used a mask to shield the edges we had no real transparency. Thus we were unable to effectively use it on more graphic backgrounds.

I however thought it should be able to use canvas to provide the solution. The code below is my solution.  Continue reading

JavaScript: console logging (with IE safety)

Every once in a while I work on a site which has some or copious amounts of javascript. Now I do not mind this at all. But it’s pretty tedious stuff writing the code and putting in loggers. And when you’re working on something and you have to test it on IE. Well let’s just say the console may cause some problems.

But rather then removing all the logging i’ve found there’s an easy solution. Building yourself a logger like structure which checks the existence of the console before writing. That way you can add logging statements without crashing the entire application. Continue reading

Javascript, keeping it clear

Note that this blog is in no way written as a “best practice” or “do it this way” kind of blog. I am not, nor do I aspire to be, the worlds greatest javascript programmer. I do however like my code clear and structured. Now lately some collegues have asked me how I write my code and that in turn prompted this blog.

In short the best way to keep your javascript clear is using namespaces. The use of namespacing is very simple and should cause you no problems. As you will come to see it will be both easy and clear for fellow developers to read and modify your code. So yes, if you wish to remain the javascript magician with obscure code that no other developer wants to touch feel free to not use them. Continue reading

A introduction to websockets.

To make a long story short websockets allow us to create a pipeline between a web client and a server. Which is great because we can push and pull all kind of data through it. This in turn allows us to create highly responsive web applications that may update information over multiple sessions.

Sound awesome doesn’t it. There’s just one catch, and you can probably guess what it is. Continue reading

Day two of the SpringOne 2GX in Washington.

It was a full day starting with breakfast and 5 one and a half hour long presentations followed by dinner and a keynote delivered by Adrian Colyer, CTO of SpringSource.

The keynote was on how application architecture has evolved over the last 10 years towards what it has become today. We started out with a static frontend client that communicated with a service layer, which in turn persisted to a database. Nowadays we have rich clients, multiple services in our service tier that in turn connect to services, websockets and/or other data sources.

Continue reading