Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor tests in Angular: how to check for a directive attribute?

I'm writing Protractor tests in Angular, and I would like to check that a directive has rendered correctly, but I'm not sure of the best way to do it in Protractor syntax.

This is what my rendered HTML looks like:

<div faqs-widget="" class="ng-scope">
<h1 class="ng-binding">My FAQs</h1>
<ul>
<!-- ngRepeat: question in data -->
<li ng-repeat="question in data" class="ng-scope ng-binding">A question</li>
<!-- end ngRepeat: question in data -->
</ul>
</div>

So ideally I'd like to check at least that there is a div with a faqs-widget property. How can I do this?

(PS: advice on what else I should test is also welcome.)

like image 707
Richard Avatar asked Nov 25 '13 16:11

Richard


1 Answers

this sounds like a unit test, but u can do it in protractor,

ptor.findElement(protractor.by.css('div[faqs-widget]').isElementPresent().then(function(v){ 
    expect(v).toBe(true);
});
like image 131
user2167582 Avatar answered Sep 27 '22 23:09

user2167582