spriteCloud / lapis-lazuli

Cucumber helper functions and scaffolding for easier test automation suite development.
Other
7 stars 7 forks source link

multi_find_all() only lists the elements with the first successfull selector #41

Closed sjieg closed 7 years ago

sjieg commented 8 years ago
irb
require 'lapis_lazuli'
include LapisLazuli
browser.goto 'google.com'

browser.multi_find_all(
  :selectors => [
    {:element => {:text => 'Google'}},
    {:a => {:text => 'Afbeelding'}},
    {:a => {:text => 'Gmail'}}
  ],
  :mode => :match_one
).length
# Expected:7, Actual: 3

browser.multi_find_all(
  :selectors => [
    {:a => {:text => 'Gmail'}},
    {:element => {:text => 'Google'}},
    {:a => {:text => 'Afbeelding'}}
  ],
  :mode => :match_one
).length
# Expected:3, Actual: 2

multi_find_all() seems to stop looking for the other selectors once it has found a result. So if the first selector has zero results, then it will find_all for the second selector, and so on.

jfinkhaeuser commented 8 years ago

Change :mode to :match_all. Does the result change?

sjieg commented 8 years ago

That will cause the find to fail because it trying to look for an element that has all 3 of the selectors to be true,, which will be never.

According to the documentation :match_all means that the elements found should match all the given selectors. :match_one means that it should match any one of the given selectors. So the difference is in _all where you expect all the elements to be given that match either one of the selectors.

Sidenote: If an element matches 2 of the 3 selectors, then it should be listed only once in the returned array.

jfinkhaeuser commented 8 years ago

Mhh, well, it's been a while. You'll make it work, I guess :)