Release of protractor-helper version 4.1.1

Walmyr Filho
The Startup
Published in
3 min readApr 30, 2020

--

Now with type definitions in the functions signatures

It is with great pleasure that I present you with the newest version of the protractor-helper library, which now provides a better experience for its users with type definitions in the functions’ signatures.

As of version 4.1.1, if you use the Visual Studio Code editor (or some other with TypeScript support), after importing the library into your test file, when you type something like helper.click(), you will be presented with the parameters that such a function expects, what types such parameters should have, which are mandatory and which are optional, in addition to the return of each function.

Let’s see some examples.

scrollToElement function signature

Notice the tooltip displayed, which provides the following information about the scrollToElement method.

The first argument we must pass is an element (elem), which is of type ElementFinder, and such an argument is mandatory.

The second argument we can pass is a timeout in milliseconds (timeoutInMs), which is optional. It is possible to identify that the argument is optional due to the question mark (?) before its type definition, which is a number.

Also, it is possible to notice that such a function returns a Promise.

Let’s look at another example, which expects more arguments.

waitForTextToBePresentInElement function signature

In the case of the waitForTextToBePresentInElement method, the first argument is also an element (elem) of type ElementFinder, which is mandatory.

The second argument is a text, which is also mandatory and is of type string.

The third argument, as in the previous example, is a timeout in milliseconds (timeoutInMs), which is optional and is of the type number.

Finally, see that this method also returns a Promise.

Now, let’s look at the example of a library method that can be used to perform an assertion.

isCurrentUrlDifferentFromBaseUrl function signature

Note that the isCurrentUrlDifferentFromBaseUrl function does not take any arguments, and returns a boolean, that is, a positive (true) or negative (false) value, which can be used to make an assertion.

Finally, let’s look at a function that expects only an optional argument, and that has no return.

setTimeout function signature

Note that the setTimeout function has only one argument, which is a number, and that argument is optional.

Also, such a function has no return, which can be perceived by the void return, which means the absence of return.

Ah, the examples presented in this post can be found on GitHub through the following URL: https://github.com/wlsf82/sample-protractor

If you are already a user of the protractor-helper library, update it to the newest version (4.1.1) and take advantage of this new functionality.

And if you write tests with the Protractor framework and still don’t use the protractor-helper library, what are you waiting for? Run npm i protractor-helper -D and install it as a dev dependency on your test project.

This post was originally published in Portuguese, and it can be found through the following URL https://talkingabouttesting.com/2020/04/29/lancamento-do-protractor-helper-versao-4-1-1/.

Talk to you next time, and good testing! 👋

--

--

Walmyr Filho
The Startup

QA Engineer, clean coder, blogger, writer, YouTuber, online teacher, mentor, member of technology communities and passionate for good music 🎶 and skateboarding