0

On one webpage, there exist a series of buttons with the same name that I need to select. I can collect these buttons through a command like

buttons = browser.find_by_name("value")

but once I select one of these buttons the rest of the elements are "Stale" and unable to be used. Is there a way, I can cycle through the elements of the list and click each one?

Morgan Thrapp
  • 9,748
  • 3
  • 46
  • 67
Jim
  • 101
  • 3
  • 9
  • Can you add more description and code example of what you're doing now? You can easily access the first and last buttons like `buttons.first` and `buttons.last`. Others can be indexed by their index `buttons[1]`. [Docs link](http://splinter.readthedocs.io/en/latest/finding.html) – bmcculley Jun 03 '16 at 06:12

1 Answers1

0

Could you link to the page where you tried this?

I am a bit surprised that the other elements go stale after clicking on of them, but oh well. This should work although it might be bit slow:

buttons = browser.find_by_name("value")
buttons_length = len(buttons)
buttons[0].click()

for i in range(1, buttons_length):
    browser.find_by_name("value")[i].click()
Harald Nordgren
  • 11,693
  • 6
  • 41
  • 65