-1

I am trying to click on this element using python-selenium bindings .There are multiple elements with the same class but different data-original-title attribute .

How can I access these elements with data-original-title="Like" directly ? instead of having to fetch first by class names then loop through elements for desired attribute .

HTML code

<div class="IconContainer js-tooltip" data-original-title="Like">

  • Are you saying elements that have a data-original-title attribute always have a unique value for it? – user3750325 Aug 01 '17 at 23:52
  • Possible duplicate of [Selenium / Python - Selecting via css selector](https://stackoverflow.com/questions/18600391/selenium-python-selecting-via-css-selector) – JeffC Aug 02 '17 at 04:32
  • Welcome to Stack Overflow! See: [How do I do X?](https://meta.stackoverflow.com/questions/253069/whats-the-appropriate-new-current-close-reason-for-how-do-i-do-x) The expectation on SO is that the user asking a question not only does research to answer their own question but also shares that research, code attempts, and results. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer! See also: [ask] – JeffC Aug 02 '17 at 04:32

1 Answers1

1

If you meant that the attribute data-original-title is always unique, you can select the element with the desired attribute value using xpath:

//div[@data-original-title='Like']
user3750325
  • 1,351
  • 1
  • 19
  • 35