Skip to content

Commit c391f21

Browse files
authored
chore: add test to double-click back (#533)
1 parent cca9a0d commit c391f21

File tree

5 files changed

+22
-31
lines changed

5 files changed

+22
-31
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
- `Ferrum::Frame#frame_element` returns the element in which the window is embedded [#524]
1414
- `Ferrum::Page#start_screencast` starts sending frames to record screencast [#494]
1515
- `Ferrum::Page#stop_screencast` stops sending frames [#494]
16-
- `Ferrum::Browser#new(incognito: false)` wether to create an incognito profile for the browser startup window, `true` by default.
16+
- `Ferrum::Browser#new(incognito: false)` whether to create an incognito profile for the browser startup window, `true` by default.
1717

1818
### Changed
1919

lib/ferrum/node.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def click(mode: :left, keys: [], offset: {}, delay: 0)
7676
when :double
7777
page.mouse.move(x: x, y: y)
7878
page.mouse.down(modifiers: modifiers, count: 2)
79+
sleep(delay)
7980
page.mouse.up(modifiers: modifiers, count: 2)
8081
when :left
8182
page.mouse.click(x: x, y: y, modifiers: modifiers, delay: delay)

spec/mouse_spec.rb

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -226,22 +226,5 @@
226226
end.to raise_error(Ferrum::MouseEventFailed)
227227
end
228228
end
229-
230-
context "double click tests" do
231-
before do
232-
browser.go_to("/double_click_test")
233-
end
234-
235-
it "double clicks properly" do
236-
browser.resize(width: 200, height: 200)
237-
log = browser.at_css("#log")
238-
239-
instructions = %w[one four one two three]
240-
instructions.each do |instruction|
241-
browser.at_css("##{instruction}").base.double_click
242-
expect(log.text).to eq(instruction)
243-
end
244-
end
245-
end
246229
end
247230
end

spec/node_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,20 @@
111111
expect(page.current_url).to eq(base_url("/"))
112112
end
113113
end
114+
115+
context "can double click" do
116+
before { page.go_to("/double_click_test") }
117+
118+
it "double clicks properly" do
119+
log = browser.at_css("#log")
120+
121+
instructions = %w[one four one two three]
122+
instructions.each do |instruction|
123+
browser.at_css("##{instruction}").click(mode: :double, delay: 0.05)
124+
expect(log.text).to eq(instruction)
125+
end
126+
end
127+
end
114128
end
115129

116130
describe "#at_xpath" do

spec/support/views/double_click_test.erb

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,16 @@
2727
}
2828
</style>
2929
<script type="text/javascript">
30-
window.onload = function() {
31-
var log = document.querySelector("#log")
32-
var boxes = document.querySelectorAll(".box")
33-
for (var i = 0; i < boxes.length; i++) {
34-
var el = boxes[i]
35-
el.ondblclick = function() {
36-
log.textContent = this.id
37-
}
38-
}
30+
window.onDblClick = function(id) {
31+
document.querySelector("#log").textContent = id;
3932
}
4033
</script>
4134
</head>
4235
<body>
43-
<div id="one" class="box"></div>
44-
<div id="two" class="box"></div>
45-
<div id="three" class="box"></div>
46-
<div id="four" class="box"></div>
36+
<div id="one" ondblclick="onDblClick('one')" class="box"></div>
37+
<div id="two" ondblclick="onDblClick('two')" class="box"></div>
38+
<div id="three" ondblclick="onDblClick('three')" class="box"></div>
39+
<div id="four" ondblclick="onDblClick('four')" class="box"></div>
4740
<div id="log"></div>
4841
</body>
4942
</html>

0 commit comments

Comments
 (0)