Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- `Ferrum::Frame#frame_element` returns the element in which the window is embedded [#524]
- `Ferrum::Page#start_screencast` starts sending frames to record screencast [#494]
- `Ferrum::Page#stop_screencast` stops sending frames [#494]
- `Ferrum::Browser#new(incognito: false)` wether to create an incognito profile for the browser startup window, `true` by default.
- `Ferrum::Browser#new(incognito: false)` whether to create an incognito profile for the browser startup window, `true` by default.

### Changed

Expand Down
1 change: 1 addition & 0 deletions lib/ferrum/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def click(mode: :left, keys: [], offset: {}, delay: 0)
when :double
page.mouse.move(x: x, y: y)
page.mouse.down(modifiers: modifiers, count: 2)
sleep(delay)
page.mouse.up(modifiers: modifiers, count: 2)
when :left
page.mouse.click(x: x, y: y, modifiers: modifiers, delay: delay)
Expand Down
17 changes: 0 additions & 17 deletions spec/mouse_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,22 +226,5 @@
end.to raise_error(Ferrum::MouseEventFailed)
end
end

context "double click tests" do
before do
browser.go_to("/double_click_test")
end

it "double clicks properly" do
browser.resize(width: 200, height: 200)
log = browser.at_css("#log")

instructions = %w[one four one two three]
instructions.each do |instruction|
browser.at_css("##{instruction}").base.double_click
expect(log.text).to eq(instruction)
end
end
end
end
end
14 changes: 14 additions & 0 deletions spec/node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@
expect(page.current_url).to eq(base_url("/"))
end
end

context "can double click" do
before { page.go_to("/double_click_test") }

it "double clicks properly" do
log = browser.at_css("#log")

instructions = %w[one four one two three]
instructions.each do |instruction|
browser.at_css("##{instruction}").click(mode: :double, delay: 0.05)
expect(log.text).to eq(instruction)
end
end
end
end

describe "#at_xpath" do
Expand Down
19 changes: 6 additions & 13 deletions spec/support/views/double_click_test.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,16 @@
}
</style>
<script type="text/javascript">
window.onload = function() {
var log = document.querySelector("#log")
var boxes = document.querySelectorAll(".box")
for (var i = 0; i < boxes.length; i++) {
var el = boxes[i]
el.ondblclick = function() {
log.textContent = this.id
}
}
window.onDblClick = function(id) {
document.querySelector("#log").textContent = id;
}
</script>
</head>
<body>
<div id="one" class="box"></div>
<div id="two" class="box"></div>
<div id="three" class="box"></div>
<div id="four" class="box"></div>
<div id="one" ondblclick="onDblClick('one')" class="box"></div>
<div id="two" ondblclick="onDblClick('two')" class="box"></div>
<div id="three" ondblclick="onDblClick('three')" class="box"></div>
<div id="four" ondblclick="onDblClick('four')" class="box"></div>
<div id="log"></div>
</body>
</html>
Loading