1

I cannot figure out how to locate ng-click in the page object file for the code below:

<a ng-click="toggleGuestParams('personal')" class="ng-click-active">Select/Unselect All</a>

There are three instances of the code but the each word in parenthesis changes. I have the following now but it doesn't seem to be working- no errors but the button is not being clicked

$$('[ng-click="toggleGuestParams(Personal)"]');

1 Answer 1

1

You are missing single quotes in your selector, and personal have to be in a lower-case:

$('[ng-click="toggleGuestParams(\'personal\')"]').click();

Note the $ to match a single element and .click() method to click the link.


no errors

The reason you had no errors is that, Protractor would not attempt to search the element(s) until there is an action or method called on it/them. In other words, $$('[ng-click="toggleGuestParams(Personal)"]'); would in essence do nothing by itself.


I, though, think that by.cssContainingText together with a partial ng-click match would be a better option here:

var selectUnselectLink = element(by.cssContainingText('a[ng-click*=personal]', 'Select/Unselect All'));
selectUnselectLink.click();

*= means "contains" here.

3
  • Still no go... both attempts return the following: Element <a ng-click="toggleGuestParams('personal')">...</a> is not clickable at point (613, 866). Other element would receive the click: <div class="title">...</div> which doesn't make sense to me as there is no other div with a title class.
    – kylokyler
    Commented Jul 6, 2017 at 0:33
  • 1
    @Kelsey well, at least we've got through the initial issue. This problem now looks application specific, which will make it difficult for me to debug..are you sure the link is not covered with an another element when you click it? What if you maximize the browser window? Thanks
    – alecxe
    Commented Jul 6, 2017 at 0:37
  • @alexce you are absolutely right. The link isn't in the viewable area, if i scroll while the test is going, it works great. Thanks, I wasn't aware the link had to be visible within the screen.
    – kylokyler
    Commented Jul 6, 2017 at 1:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.