Reputation: 12518
I'm trying to use the Capybara Node::Element click with the offset as defined in the Rdoc.
Basically, I want to use the click method on an element, but clicking NOT on the center of the element, but offset to the left. I don't want to do the action.move_to methods.
#click(*key_modifiers = [], offset = {x: nil, y: nil}) ⇒ Capybara::Node::Element
Click the Element
Parameters:
*key_modifiers (Array<:alt, :control, :meta, :shift>) (defaults to: [])
— Keys to be held down when clicking
offset (Hash) (defaults to: {x: nil, y: nil}) — x and y coordinates
to offset the click location from the top left corner of the element.
If not specified will click the middle of the element.
I'm just not sure how to use this if I want the default key_modifier ('[ ]'). When I try this, I get a not a key modifier error.
elem = find(some_xpath)
elem.click([], {x: -20, y: nil})
ArgumentError:
[] is not a modifier key, expected one of [:control, :shift, :alt,
:command, :meta]
I tried skipping [] and it doesn't seem to do the offset
elem.click({x: -100 y:nil})
Upvotes: 0
Views: 1267
Reputation: 49870
You need to specify both x any y, you can't specify nil
for one of them
click(x: -100, y: 0)
Upvotes: 3