2

I have this in view source

<div class="row-fluid:>
<div class="span4">
<div class="well tile table-clickable" ng-click="move('mjass')">
<h3> Music Jass </h3>
<div class="row-fluid cellBody">
<div class="span5">
<i class=" some text"
</div>

There are 4 more div classes like the complete section above. One section for rock, one more section for classical so I want to click specific to a particular ng-Click. (only jass or rock or classical) for example I should click only "move('mjass') here

In Protractor in using chrome driver with selenium in .js file

I used, element(by.className('well tile table-cilckable')).click() and it worked successfully But since there are lots of different classes, it always takes the first and clicks it, so instead i need to use both class and ng-click.

1 Answer 1

3

You can use a partial match on the ng-click attribute:

$("[ng-click*=mjass]").click();

where $ is a shortcut to element(by.css()).

Or, you can add use an XPath expression and check the section title (a little bit less recommended by the Style Guide):

element(by.xpath("//div[contains(@class, 'table-clickable') and contains(h3, 'Music Jass')]")).click();
Sign up to request clarification or add additional context in comments.

2 Comments

Sorry, this was my first post here and did not no how to accept the answer, no i have selected(clicked) the tick mark next to the answer. Hope this is correct. Thanks again!
@user7375268 thank you for respecting the rules and glad it worked for you.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.