-2

How can I select the last button in this code? the only thing that changes is the value.

button class="btn btn-link btn-star" data-value="26">/button>

button class="btn btn-link btn-star" data-value="27">/button>

  • @JeffC Please don't spam all the questions with _...See: How do I do X?..._ comment as specifically this question have a accepted answer and additionally received multiple answers. I would suggest you to take some time to understand the _usecases_ OP refers to. – undetected Selenium Apr 26 '19 at 08:37
  • @DebanjanB It doesn't matter whether it has an answer or not, it's not a well formed question. Maybe you should read [ask] again so you know what a good question looks like? The better question is why aren't you asking OP to clean up their question? – JeffC Apr 26 '19 at 12:54
  • @JeffC None of the StackOverflow best practices mattered to you in 6 years and nor would be in future. Keep spamming, you're of course, welcome to ignore the community guidelines. – undetected Selenium Apr 26 '19 at 12:57
  • @DebanjanB OK... this question has malformed/incomplete HTML, the HTML is not formatted, there is no code nor code attempts, and the description isn't exactly clear. You are saying there's nothing to fix/improve here? – JeffC Apr 26 '19 at 13:03

2 Answers2

0

Try css selector button.btn.btn-link.btn-star:last

Jeni
  • 1,088
  • 12
  • 30
0

Try the following Xpath to find the last element.

//button[@class='btn btn-link btn-star'][last()]
KunduK
  • 32,888
  • 5
  • 17
  • 41