Skip to content

Commit 237d991

Browse files
committed
Add tests for node #css #at_css #xpath #at_xpath
1 parent 7123dd0 commit 237d991

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

spec/node_spec.rb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,43 @@ module Ferrum
4242
expect { browser.at_xpath("//a[text() = 'JS redirect']") }.not_to raise_error
4343
end
4444

45+
it "#at_xpath searches relatively current node" do
46+
browser.go_to("/ferrum/with_js")
47+
48+
p = browser.at_xpath("//p[@id='with_content']")
49+
50+
expect(p.at_xpath("a").text).to eq("Open for match")
51+
expect(p.at_xpath(".//a").text).to eq("Open for match")
52+
end
53+
54+
it "#xpath searches relatively current node" do
55+
browser.go_to("/ferrum/with_js")
56+
57+
p = browser.at_xpath("//p[@id='with_content']")
58+
links = p.xpath("a")
59+
60+
expect(links.size).to eq(1)
61+
expect(links.first.text).to eq("Open for match")
62+
end
63+
64+
it "#at_css searches relatively current node" do
65+
browser.go_to("/ferrum/with_js")
66+
67+
p = browser.at_css("p#with_content")
68+
69+
expect(p.at_css("a").text).to eq("Open for match")
70+
end
71+
72+
it "#css searches relatively current node" do
73+
browser.go_to("/ferrum/with_js")
74+
75+
p = browser.at_xpath("//p[@id='with_content']")
76+
links = p.css("a")
77+
78+
expect(links.size).to eq(1)
79+
expect(links.first.text).to eq("Open for match")
80+
end
81+
4582
context "when the element is not in the viewport" do
4683
before do
4784
browser.go_to("/ferrum/with_js")

spec/runtime_spec.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
module Ferrum
44
describe Frame::Runtime do
5-
it "supports executing multiple lines of javascript" do
6-
browser.execute <<-JS
7-
var a = 1
8-
var b = 2
9-
window.result = a + b
10-
JS
11-
expect(browser.evaluate("window.result")).to eq(3)
5+
context "execute" do
6+
it "supports executing multiple lines of javascript" do
7+
browser.execute <<-JS
8+
var a = 1
9+
var b = 2
10+
window.result = a + b
11+
JS
12+
expect(browser.evaluate("window.result")).to eq(3)
13+
end
1214
end
1315

1416
context "evaluate" do

0 commit comments

Comments
 (0)