go-rod / rod

A Chrome DevTools Protocol driver for web automation and scraping.
https://go-rod.github.io
MIT License
5k stars 328 forks source link

How to open a new Chrome window while using remote control #1059

Closed J404J closed 1 month ago

J404J commented 1 month ago

Rod Version: v0.116.0

Question

How can I control Chrome to open a new window or detach an open tab into a separate window while using remote control?

Why

The reason for this requirement is: The target website needs to be displayed in the foreground to run. Even if multiple tabs are open, only the current tab's page will run.

Ps

Additionally, if there are any other methods to operate pages that need to be kept in the foreground to run?

github-actions[bot] commented 1 month ago

Please fix the format of your markdown:

3 MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "# Question"]
6 MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "# Why"]
7:36 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1]
10 MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "# Ps"]

generated by check-issue

ysmood commented 1 month ago

The NewWindow option:

page, err := browser.Page(proto.TargetCreateTarget{
        URL: "http://example.com",
        NewWindow: true,
    })
ysmood commented 1 month ago

Read this example if you want better control:

https://github.com/go-rod/rod/blob/2d3e61f379eaddca6cf029c4060c34271064e641/lib/examples/use-rod-like-chrome-extension/main.go

J404J commented 1 month ago

The NewWindow option:

page, err := browser.Page(proto.TargetCreateTarget{
      URL: "http://example.com",
      NewWindow: true,
  })

Thank you very much, it‘s helpful to me.