Skip to content

Commit c715695

Browse files
committed
#238 Refactor specs
1 parent f0906db commit c715695

File tree

4 files changed

+33
-37
lines changed

4 files changed

+33
-37
lines changed

CHANGELOG.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,18 @@ a block with this page, after which the page is closed.
3333
- `Ferrum::Context#has_target?` -> `Ferrum::Context#target?`
3434
- We now start looking for Chrome first instead of Chromium, the order for checking binaries has changed
3535
- Multiple methods are moved into `Utils`:
36-
- Ferrum.with_attempts -> Ferrum::Utils::Attempt.with_retry
37-
- Ferrum.started -> Ferrum::Utils::ElapsedTime.start
38-
- Ferrum.elapsed_time -> Ferrum::Utils::ElapsedTime.elapsed_time
39-
- Ferrum.monotonic_time -> Ferrum::Utils::ElapsedTime.monotonic_time
40-
- Ferrum.timeout? -> Ferrum::Utils::ElapsedTime.timeout?
41-
- Ferrum.windows? -> Ferrum::Utils::Platform.windows?
42-
- Ferrum.mac? -> Ferrum::Utils::Platform.mac?
43-
- Ferrum.mri? -> Ferrum::Utils::Platform.mri?
36+
- `Ferrum.with_attempts` -> `Ferrum::Utils::Attempt.with_retry`
37+
- `Ferrum.started` -> `Ferrum::Utils::ElapsedTime.start`
38+
- `Ferrum.elapsed_time` -> `Ferrum::Utils::ElapsedTime.elapsed_time`
39+
- `Ferrum.monotonic_time` -> `Ferrum::Utils::ElapsedTime.monotonic_time`
40+
- `Ferrum.timeout?` -> `Ferrum::Utils::ElapsedTime.timeout?`
41+
- `Ferrum.windows?` -> `Ferrum::Utils::Platform.windows?`
42+
- `Ferrum.mac?` -> `Ferrum::Utils::Platform.mac?`
43+
- `Ferrum.mri?` -> `Ferrum::Utils::Platform.mri?`
44+
45+
### Fixed
46+
47+
- `Ferrum::Node#selected`, `Ferrum::Node#select` to work in frame scope
4448

4549
## [0.11](https://github.com/rubycdp/ferrum/compare/v0.10.2...v0.11) - (Mar 11, 2021) ##
4650

spec/node_spec.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,6 @@ module Ferrum
112112
end
113113

114114
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
123115
frame = browser.at_xpath("//iframe[@name='frame']").frame
124116
expect(frame.at_xpath("//*[@id='select']").selected.map(&:text)).to eq(["One"])
125117
end
@@ -208,14 +200,6 @@ module Ferrum
208200
end
209201

210202
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
219203
frame = browser.at_xpath("//iframe[@name='frame']").frame
220204
expect(frame.at_xpath("//*[@id='select']").select("Two", by: :text).selected.map(&:text)).to eq(["Two"])
221205
end

spec/support/views/form.erb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
21
<h1>Form</h1>
32

43
<form action="/form" method="post" novalidate>
5-
64
<p>
75
<label for="form_title">Title</label>
86
<select name="form[title]" id="form_title" class="title">
@@ -144,12 +142,12 @@
144142
</p>
145143

146144
<p>
147-
<label for="form_description">Description</label></br>
145+
<label for="form_description">Description</label><br/>
148146
<textarea name="form[description]" id="form_description">Descriptive text goes here</textarea>
149-
<p>
147+
</p>
150148

151149
<p>
152-
<label for="form_newline">NewLine</label></br>
150+
<label for="form_newline">NewLine</label><br/>
153151
<textarea name="form[newline]" id="form_newline">
154152

155153
New line after and before textarea tag
@@ -298,13 +296,13 @@ New line after and before textarea tag
298296

299297
<p>
300298
<span>First address<span>
301-
<label for='address1_street'>Street</label>
299+
<label for="address1_street">Street</label>
302300
<input type="text" name="form[addresses][][street]" value="" id="address1_street">
303301

304-
<label for='address1_city'>City</label>
302+
<label for="address1_city">City</label>
305303
<input type="text" name="form[addresses][][city]" value="" id="address1_city">
306304

307-
<label for='address1_country'>Country</label>
305+
<label for="address1_country">Country</label>
308306
<select name="form[addresses][][country]" id="address1_country">
309307
<option selected>France</option>
310308
<option>Ukraine</option>
@@ -313,13 +311,13 @@ New line after and before textarea tag
313311

314312
<p>
315313
<span>Second address<span>
316-
<label for='address2_street'>Street</label>
314+
<label for="address2_street">Street</label>
317315
<input type="text" name="form[addresses][][street]" value="" id="address2_street">
318316

319-
<label for='address2_city'>City</label>
317+
<label for="address2_city">City</label>
320318
<input type="text" name="form[addresses][][city]" value="" id="address2_city">
321319

322-
<label for='address2_country'>Country</label>
320+
<label for="address2_country">Country</label>
323321
<select name="form[addresses][][country]" id="address2_country">
324322
<option>France</option>
325323
<option selected>Ukraine</option>
@@ -580,10 +578,10 @@ New line after and before textarea tag
580578

581579
<input type="hidden" name="form[data]" value="TWTW"/>
582580
<p>
583-
<button formaction='/redirect_307'>Go 307</button>
581+
<button formaction="/redirect_307">Go 307</button>
584582
</p>
585583
<p>
586-
<button formaction='/redirect_308'>Go 308</button>
584+
<button formaction="/redirect_308">Go 308</button>
587585
</p>
588586
</form>
589587

@@ -677,3 +675,5 @@ New line after and before textarea tag
677675
<option value=""></option>
678676
<option value="AU">Australia</option>
679677
</select>
678+
679+
<iframe src="/ferrum/form_iframe" name="frame"></iframe>

spec/support/views/form_iframe.erb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<html>
2+
<body>
3+
<select id="select">
4+
<option>One</option>
5+
<option>Two</option>
6+
</select>
7+
</body>
8+
</html>

0 commit comments

Comments
 (0)