File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,13 @@ def focus
30
30
tap { page . command ( "DOM.focus" , slowmoable : true , nodeId : node_id ) }
31
31
end
32
32
33
+ def focusable?
34
+ focus
35
+ true
36
+ rescue BrowserError => e
37
+ e . message == "Element is not focusable" ? false : raise
38
+ end
39
+
33
40
def blur
34
41
tap { evaluate ( "this.blur()" ) }
35
42
end
Original file line number Diff line number Diff line change @@ -155,5 +155,19 @@ module Ferrum
155
155
expect ( el1 == el2 ) . to be false
156
156
end
157
157
end
158
+
159
+ describe "#focusable?" do
160
+ before do
161
+ browser . go_to ( "/ferrum/form" )
162
+ end
163
+
164
+ context "with hidden input" do
165
+ it { expect ( browser . at_css ( "#hidden_input" ) . focusable? ) . to eq ( false ) }
166
+ end
167
+
168
+ context "with regular input" do
169
+ it { expect ( browser . at_css ( "#form_name" ) . focusable? ) . to eq ( true ) }
170
+ end
171
+ end
158
172
end
159
173
end
Original file line number Diff line number Diff line change @@ -668,3 +668,7 @@ New line after and before textarea tag
668
668
< p >
669
669
< input id ="special " {custom} ="abcdef " value ="custom attribute "/>
670
670
</ p >
671
+
672
+ < p >
673
+ < input id ="hidden_input " style ="display: none "/>
674
+ </ p >
You can’t perform that action at this time.
0 commit comments