Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does headless mode have no effect #1132

Closed
rew1nter opened this issue Oct 25, 2024 · 3 comments
Closed

Why does headless mode have no effect #1132

rew1nter opened this issue Oct 25, 2024 · 3 comments
Labels
question Questions related to rod

Comments

@rew1nter
Copy link

Rod Version: v0.116.2

The code to demonstrate your question

Headless(true|false) has no effect on the browser here. The browser is always shown

package main

import (
	"github.com/go-rod/rod"
	"github.com/go-rod/rod/lib/launcher"
)

func main() {
	// make sure target browser is closed
	path := "/usr/bin/chromium"
	// launch installed browser
	wsURL := launcher.NewUserMode().Bin(path).Headless(true).MustLaunch()
	// connect to the browser
	browser := rod.New().ControlURL(wsURL).MustConnect().NoDefaultDevice()

	browser.MustPage("http://127.0.0.1:80/#")
}

What you got

The browser always shown

What you expect to see

The browser shown or hidden based on the flag

What have you tried to solve the question

Such as after modifying some source code of Rod you are able to get rid of the problem.

@rew1nter rew1nter added the question Questions related to rod label Oct 25, 2024
Copy link

Please fix the format of your markdown:

2 MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Above] [Context: "## The code to demonstrate your question"]

generated by check-issue

@ysmood
Copy link
Member

ysmood commented Oct 26, 2024

You are probably using the last browser. UserMode is a raw mode, you literally have to manage everything, if you don't close the browser, it will remain open. In this mode, rod will not help you to close the browser.

@rew1nter
Copy link
Author

You are right!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions related to rod
Projects
None yet
Development

No branches or pull requests

2 participants