I am using rspec-watir to automate some tests, and recently came into a strange issue.
Background: I have a method called select_cards(cards)
created that does a search, selects 16 (specifically 16) cards, then adds them to a section... recently I modified my configuration so that the screen window starts at 1920x1080 ( @browser.window.resize_to(1920, 1080)
)
Since doing this, whenever I run select_cards(cards)
it only selects 12 cards instead of 16. However, when I comment out the window.resize_to
method, it successfully grabs all 16
Any idea why resizing the window would cause a behavior change? Any thoughts on how I could workaround this?
Code snippet for how select_cards(cards)
works:
def select_cards(cards)
@browser.button(:class, 'add-cards').click
# this runs a generic search to return all cards
search_modal = @browser.div(:class, 'quick-search')
search_modal.button(:class, 'test-quick-search').click
results = @browser.div(:class, 'search-results')
# This #take() passes in how many cards to click on--as stated; 16
cards = results.divs(:class, 'card selectable')
cards.take(cards).each do |assets|
assets.click
end
end