File tree Expand file tree Collapse file tree 2 files changed +46
-7
lines changed Expand file tree Collapse file tree 2 files changed +46
-7
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,43 @@ module Ferrum
42
42
expect { browser . at_xpath ( "//a[text() = 'JS redirect']" ) } . not_to raise_error
43
43
end
44
44
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
+
45
82
context "when the element is not in the viewport" do
46
83
before do
47
84
browser . go_to ( "/ferrum/with_js" )
Original file line number Diff line number Diff line change 2
2
3
3
module Ferrum
4
4
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
12
14
end
13
15
14
16
context "evaluate" do
You can’t perform that action at this time.
0 commit comments