@@ -110,6 +110,19 @@ module Ferrum
110
110
. to raise_exception ( Ferrum ::JavaScriptError , /Element is not a <select> element/ )
111
111
end
112
112
end
113
+
114
+ it "returns selected options within frame" do
115
+ browser . execute <<-JS
116
+ document.body.innerHTML += "<iframe src='about:blank' name='frame'>";
117
+ var iframeDocument = document.querySelector("iframe[name='frame']").contentWindow.document;
118
+ var content = "<html><body><select id='select'><option>One</option></select></body></html>";
119
+ iframeDocument.open("text/html", "replace");
120
+ iframeDocument.write(content);
121
+ iframeDocument.close();
122
+ JS
123
+ frame = browser . at_xpath ( "//iframe[@name='frame']" ) . frame
124
+ expect ( frame . at_xpath ( "//*[@id='select']" ) . selected . map ( &:text ) ) . to eq ( [ "One" ] )
125
+ end
113
126
end
114
127
115
128
describe "#select" do
@@ -193,6 +206,19 @@ module Ferrum
193
206
. to eq ( [ "" ] )
194
207
end
195
208
end
209
+
210
+ it "picks option within frame" do
211
+ browser . execute <<-JS
212
+ document.body.innerHTML += "<iframe src='about:blank' name='frame'>";
213
+ var iframeDocument = document.querySelector("iframe[name='frame']").contentWindow.document;
214
+ var content = "<html><body><select id='select'><option>One</option><option>Two</option></select></body></html>";
215
+ iframeDocument.open("text/html", "replace");
216
+ iframeDocument.write(content);
217
+ iframeDocument.close();
218
+ JS
219
+ frame = browser . at_xpath ( "//iframe[@name='frame']" ) . frame
220
+ expect ( frame . at_xpath ( "//*[@id='select']" ) . select ( "Two" , by : :text ) . selected . map ( &:text ) ) . to eq ( [ "Two" ] )
221
+ end
196
222
end
197
223
198
224
context "when the element is not in the viewport" do
0 commit comments