Skip to content

Commit 600d63d

Browse files
committed
feat: Implement Ferrum::Page#activate
1 parent c6f4801 commit 600d63d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
- `Ferrum::Node#exists?` check whether the node in ruby world still exists in the DOM tree.
99
- `Ferrum::Cookies#store` stores all cookies of current page in a file.
1010
- `Ferrum::Cookies#load` Loads all cookies from the file and sets them for current page.
11-
- `Ferrum::Page#screenshot` supports webp image format
11+
- `Ferrum::Page#screenshot` supports webp image format.
12+
- `Ferrum::Page#activate` activates the target for the given page.
1213

1314
### Changed
1415

lib/ferrum/page.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,19 @@ def bypass_csp(enabled: true)
336336
enabled
337337
end
338338

339+
#
340+
# Activates (focuses) the target for the given page. When you have multiple tabs you work with, and you need to switch a given one.
341+
#
342+
# @return [Boolean]
343+
#
344+
# @example
345+
# page.activate # => true
346+
#
347+
def activate
348+
command("Target.activateTarget", targetId: target_id)
349+
true
350+
end
351+
339352
def command(method, wait: 0, slowmoable: false, **params)
340353
iteration = @event.reset if wait.positive?
341354
sleep(@options.slowmo) if slowmoable && @options.slowmo.positive?

0 commit comments

Comments
 (0)