Loren
Loren

Reputation: 14856

How to click all matching elements in Webdriver?

How do you click all elements that match a selector, instead of just the first one?

elems = browser.elements '.item-checkbox'
console.log elems
for elem in elems
  # neither of these work
  browser.click elem
  elem.click()

{ state: 'success',
  sessionId: '66fe2543-7b28-40e7-8bbb-d7da7d2af928',
  hCode: 1564933402,
  value: 
   [ { ELEMENT: '702' },
     { ELEMENT: '703' },
     { ELEMENT: '704' },
     { ELEMENT: '705' },
     { ELEMENT: '706' },
     { ELEMENT: '707' } ],
  class: 'org.openqa.selenium.remote.Response',
  status: 0 }

Upvotes: 2

Views: 196

Answers (1)

garajo
garajo

Reputation: 756

http://webdriver.io/api/protocol/elementIdClick.html

res.value.forEach(function(elem) {

   browser.elementIdClick(elem.Element, function(err, res) {

   })
})

https://github.com/webdriverio/webdriverio/issues/273

Upvotes: 1

Related Questions