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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
node's own frame
- `Node#moving?` returned `true` for a node that wasn't moving and `false` for one that was. Its default delay is now
50ms instead of 10ms, which missed a slowly moving node, set it with `FERRUM_NODE_MOVING_CHECK`
- `Node#click` and `#find_position` on a CSS-transformed node whose content quads can't be computed aimed by its
untransformed size and could miss it, now they aim at the center of its bounding rect. An SVG node raised
`JSON::GeneratorError` there [#695]

### Removed
- `#evaluate_async`, `#evaluate_func` and `#evaluate_on`, use `#evaluate` and `Node#evaluate`, and
Expand Down
8 changes: 5 additions & 3 deletions lib/ferrum/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -714,9 +714,11 @@ def exists?
private

def bounding_rect_coordinates
evaluate <<~JS
[this.getBoundingClientRect().left + (this.offsetWidth / 2),
this.getBoundingClientRect().top + (this.offsetHeight / 2)]
evaluate(<<~JS)
function() {
const { left, top, width, height } = this.getBoundingClientRect();
return [left + (width / 2), top + (height / 2)];
}
JS
end

Expand Down
11 changes: 11 additions & 0 deletions spec/node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,17 @@

expect(browser.url).to eq(base_url("/"))
end

it "clicks the element by its bounding rect when it's transformed" do
browser.go_to("/simple")
link = browser.at_css("#nav")
# Rotated, the link covers the center of its bounding rect, but little else of it.
link.execute("this.style.cssText = 'display: inline-block; width: 200px; height: 20px; transform: rotate(45deg)'")

link.click

expect(browser.url).to eq(base_url("/"))
end
end

it "synchronizes page loads properly" do
Expand Down
Loading