mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Raise error if only x or only y are provided for click offset
This commit is contained in:
parent
0a8400d1cd
commit
45947902aa
2 changed files with 10 additions and 1 deletions
|
@ -153,7 +153,9 @@ module Capybara
|
|||
# @option offset [Integer] y Y coordinate to offset the click location from the top left corner of the element
|
||||
# @return [Capybara::Node::Element] The element
|
||||
def click(*keys, wait: nil, **offset)
|
||||
synchronize(wait) { base.click(keys, offset) }
|
||||
raise ArgumentError, 'You must specify both x: and y: for a click offset' if nil ^ offset[:x] ^ offset[:y]
|
||||
|
||||
synchronize(wait) { base.click(Array(keys), offset) }
|
||||
self
|
||||
end
|
||||
|
||||
|
|
|
@ -406,6 +406,13 @@ Capybara::SpecHelper.spec 'node' do
|
|||
expect(locations[:y].to_f).to be_within(1).of(5)
|
||||
end
|
||||
|
||||
it 'should raise error if both x and y values are not passed' do
|
||||
@session.visit('with_js')
|
||||
el = @session.find(:css, '#click-test')
|
||||
expect { el.click(x: 5) }.to raise_error ArgumentError
|
||||
expect { el.click(x: nil, y: 3) }.to raise_error ArgumentError
|
||||
end
|
||||
|
||||
it 'should be able to click a table row', requires: [:js] do
|
||||
@session.visit('/tables')
|
||||
tr = @session.find(:css, '#agent_table tr:first-child').click
|
||||
|
|
Loading…
Add table
Reference in a new issue