Skip to content

Commit

Permalink
feat: Implement Ferrum::Page#activate
Browse files Browse the repository at this point in the history
  • Loading branch information
route committed Nov 19, 2024
1 parent c6f4801 commit 600d63d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
- `Ferrum::Node#exists?` check whether the node in ruby world still exists in the DOM tree.
- `Ferrum::Cookies#store` stores all cookies of current page in a file.
- `Ferrum::Cookies#load` Loads all cookies from the file and sets them for current page.
- `Ferrum::Page#screenshot` supports webp image format
- `Ferrum::Page#screenshot` supports webp image format.
- `Ferrum::Page#activate` activates the target for the given page.

### Changed

Expand Down
13 changes: 13 additions & 0 deletions lib/ferrum/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,19 @@ def bypass_csp(enabled: true)
enabled
end

#
# Activates (focuses) the target for the given page. When you have multiple tabs you work with, and you need to switch a given one.
#
# @return [Boolean]
#
# @example
# page.activate # => true
#
def activate
command("Target.activateTarget", targetId: target_id)
true
end

def command(method, wait: 0, slowmoable: false, **params)
iteration = @event.reset if wait.positive?
sleep(@options.slowmo) if slowmoable && @options.slowmo.positive?
Expand Down

0 comments on commit 600d63d

Please sign in to comment.