Skip to content

Commit f435ba9

Browse files
committed
fill CHANGELOG/README for implemented Ferrum::Browser#wait_for_selector method
1 parent cf74591 commit f435ba9

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### Added
44

5+
- `Ferrum::Browser#wait_for_selector`: returns instance of `Ferrum::Node` that's matched the provided selector.
56
- Alias `Ferrum::Frame#content=` to `Ferrum::Frame#set_content`
67
- Alias `Ferrum::Node#propery` to `Ferrum::Node#[]`
78
- Implement `Ferrum::Network#blacklist=` and `Ferrum::Network#whitelist=`

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,18 @@ browser.go_to("https://google.com/")
343343
browser.body # => '<html itemscope="" itemtype="http://schema.org/WebPage" lang="ru"><head>...
344344
```
345345

346+
#### wait_for_selector : `Node`
347+
348+
```ruby
349+
browser.wait_for_selector(css: "body", timeout: 5000) # => [Node]
350+
browser.wait_for_selector(xpath: "//body", interval: 200) # => [Node]
351+
```
352+
353+
* options `Hash`
354+
* `:css` (String) - selector in css format, not specified by default.
355+
* `:xpath` (String) - selector in xpath format, not specified by default.
356+
* `:timeout` (Integer) - timeout for the selector-waiting in milliseconds, 3000 ms by default.
357+
* `:interval` (Integer) - interval that used to compute attempts for the selector-waiting (max attempts = timeout / interval), 100 by default.
346358

347359
## Screenshots
348360

lib/ferrum/frame/dom.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ def wait_for_selector(css: nil, xpath: nil, timeout: 3000, interval: 100)
4646
return reject(new Error("Not found element match the selector: " + selector));
4747
}
4848
var element = isXpath
49-
? document.
50-
evaluate(selector, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue
49+
? document.evaluate(selector, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue
5150
: document.querySelector(selector);
5251
if (element !== null) {
5352
return resolve(element);

0 commit comments

Comments
 (0)