
So now that we have our system set up for Web App testing, we can now start with writing our first test using Protractor and AngularJS.
For a Protractor test to run, we need two files written in AngularJS.
First is the configuration file, which describes what the configuration of the environment will be, in which the test(s) will be run. It has the description of the URL of the web app under test, the environment variables that are shared by all the tests and test suites, the description of the test suites that are to be run, how to link to the Selenium server and the Specification file, which is the second file required, that has the source code definition of the tests.
The specification file has the definition of all the source code that is the automated test to be run on the web app. The specification has tests written in ‘it’ blocks, which constitute a test case of the test suite. One specification file represents a single test suite.
We first start by writing down the configuration. The selenium server, when up, is accessible at http://localhost:4444/wd/hub and the specification file will be addressed relative to the current directory in which the configuration file itself is. So this is how the configuration file, myconfig.js, should look like:
The specification file, mytests.js, has tests that you would run in your test suite:
This test attempts to navigate to the AngularJS homepage and uses its first example code enters my name in the text field and then verifies that the effect of it is successfully reflected in the message field below it.
The describe() method assigns a descriptor to the test suite, here it is ‘My First Test‘. The it()
block here describes a single test case, and there can be many more in a suite. Every it() block has its own descriptor too. These descriptors help in preparing more readable reports.
We use the browser object’s get() method to open the URL in the browser configured in the configuration file. Since we didn’t configure any, the default browser’s, Google Chrome’s, instance is opened. The element object is used to identify and locate Angular specific elements of the web page. We use the ng-model attribute of the desired element using by.model() location strategy and type in the text value, using the sendKeys() method.
Similarly, we locate another element of the page, where the message is to be displayed, using the ng-binding Angular attribute, through the by.binding() strategy.
The expect() method is used to create assertions, necessary conditions to be checked, in Protractor based tests. We compare the message retrieved from the message field with the expected message using the toEqual() assertion method.
Now, to run this test, we first need to start up the selenium server. Open a terminal window and type
webdriver-manager start
If the webdriver reports any missing jars, it is because of the frequent updates to protractor, just type
webdriver-manager --standalone update
and wait for the webdriver wrapper to update.
The active Selenium Server instances can be viewed by following the URL http://localhost:4444/wd/hub/static/resource/hub.html on any of the browsers.

Open another terminal window and navigate to the directory that has the configuration file(myconfig.js). Then type
protractor myconfig.js
This would fire up the tests in the specification file. A report would be verbosely printed to the same terminal window. At the end of the execution of the tests, the status of the test is displayed.

We can also see the details of the session on the Webdriver hub page.

Though, in the above case, you’d have to be very fast as the test is really trivial and gets executed very quickly.
In case the test fails, the assertions that failed are also reported. But if the test fails somewhere else, it becomes a nightmare to actually trace to failure, scrolling through the ever-winding stack-trace printed.
In our next post, we would learn how to integrate the Jasmine report generation with our tests, which would allow us to produce better and more presentable reports of our test runs.
Till then, adios!
Good information. Lucy me Ifounnd yokur site by chance (stumbleupon).
I’ve saved itt forr later!
hеllo there and thank you for your information – I’ve certainly
picked up anything new from right here. I did however exρertise a few technical issսes using this web site, since I experienced to reload the wеb site mɑny times previоսs to I could
get it to load рroperly. I had been wondering if your һosting is OK?
Ν᧐t that I’m complaining, but sluggish ⅼoading
instances times wiⅼl sometimes affect yoսr placement in google and could
damage your high quaⅼity score if advertising and marketіng with Adwords.
Well I’m adding this RSS to my e-mail and can looк out for a lot more of your
respectiνe intriguing content. Make sure you update this again soon.
Thanks for the feedback! We will look into the load times
It is interesting. Tell to me, please – where to me to learn more about it?
The matchless answer 😉
Equilibrado
Dispositivos de balanceo: importante para el operación uniforme y efectivo de las equipos.
En el entorno de la innovación moderna, donde la productividad y la fiabilidad del aparato son de máxima relevancia, los sistemas de balanceo cumplen un papel crucial. Estos equipos adaptados están desarrollados para ajustar y estabilizar elementos rotativas, ya sea en equipamiento industrial, automóviles de movilidad o incluso en dispositivos caseros.
Para los técnicos en mantenimiento de dispositivos y los técnicos, operar con aparatos de balanceo es fundamental para promover el funcionamiento suave y fiable de cualquier aparato dinámico. Gracias a estas opciones avanzadas innovadoras, es posible disminuir sustancialmente las movimientos, el sonido y la esfuerzo sobre los soportes, prolongando la longevidad de piezas costosos.
Asimismo importante es el tarea que cumplen los equipos de equilibrado en la soporte al usuario. El asistencia especializado y el mantenimiento permanente aplicando estos dispositivos permiten dar servicios de alta estándar, aumentando la contento de los compradores.
Para los dueños de proyectos, la contribución en sistemas de equilibrado y medidores puede ser importante para mejorar la productividad y eficiencia de sus sistemas. Esto es sobre todo trascendental para los emprendedores que administran pequeñas y pequeñas emprendimientos, donde cada aspecto importa.
También, los equipos de calibración tienen una amplia utilización en el campo de la prevención y el gestión de nivel. Habilitan localizar eventuales errores, reduciendo reparaciones caras y daños a los dispositivos. Incluso, los resultados generados de estos dispositivos pueden aplicarse para optimizar sistemas y aumentar la presencia en sistemas de búsqueda.
Las campos de utilización de los aparatos de calibración cubren variadas ramas, desde la fabricación de bicicletas hasta el supervisión del medio ambiente. No interesa si se habla de enormes elaboraciones industriales o reducidos locales caseros, los aparatos de calibración son indispensables para promover un rendimiento efectivo y sin detenciones.