S
S
Sergey Nikolaev2015-06-24 12:08:34
JavaScript
Sergey Nikolaev, 2015-06-24 12:08:34

How to select an element through Protractor Angular?

Friends, I just started to study writing tests, I ran into the problem of selecting elements.
For example, there is a button, how to select it from the protractor? Add an id to each element of the page, to write tests, or what? Is there more advanced documentation than this UPDATE: Made a custom element lookup
<a ng-click="vm.showMore()">Загрузить ещё</a>

by.addLocator('aText',
    function(buttonText, opt_parentElement, opt_rootSelector) {
        var using = opt_parentElement || document,
            a = using.querySelectorAll('a');
        return Array.prototype.filter.call(a, function(a) {
            return a.textContent === a;
        });
    });

// использование 
element(by.aText('Загрузить ещё')).click();

It says element not found...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Blokhin, 2015-06-24
@TITnet

angular.github.io/protractor/#/locators
by.css('a[ng-click="vm.showMore()"]'); for example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question