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

how to hide pop window when using headless #1116

Open
Q191 opened this issue Sep 27, 2024 · 9 comments
Open

how to hide pop window when using headless #1116

Q191 opened this issue Sep 27, 2024 · 9 comments
Labels
question Questions related to rod

Comments

@Q191
Copy link

Q191 commented Sep 27, 2024

Rod Version: v0.116.2

The code to demonstrate your question

  1. Clone Rod to your local and cd to the repository:

    git clone https://github.com/go-rod/rod
    cd rod
  2. Use your code to replace the content of function TestRod in file rod_test.go.

  3. Test your code with: go test -run TestRod, make sure it fails as expected.

  4. Replace ALL THE CONTENT under "The code to demonstrate your question" with your TestRod function, like below:

const EDGE_BINARY_PATH = "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"

func main() {
	l := launcher.New().Bin(EDGE_BINARY_PATH).Headless(true)
	lUrl := l.MustLaunch()
	browser := rod.New().ControlURL(lUrl).Trace(true).MustConnect()
	page := browser.MustPage("https://github.com/go-rod/rod")
	defer func() {
		page.Close()
		page.Browser().Close()
		l.Cleanup()
	}()
	time.Sleep(10 * time.Second)
}

What you got

a empty popup window

What you expect to see

no popup window

What have you tried to solve the question

try add

cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}

to all cmd, not work

@Q191 Q191 added the question Questions related to rod label Sep 27, 2024
Copy link

Please fix the format of your markdown:

46 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"]
46 MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
48 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"]

generated by check-issue

@moxcomic
Copy link

Did a white box pop up? I encountered this issue as well, but it only happens on Windows.

@Q191
Copy link
Author

Q191 commented Oct 4, 2024

Did a white box pop up? I encountered this issue as well, but it only happens on Windows.

yes

@ysmood
Copy link
Member

ysmood commented Oct 6, 2024

Disable leakless might help.

@moxcomic
Copy link

moxcomic commented Oct 6, 2024

Disable leakless might help.

In fact, I've always had leakless disabled, yet the issue still persists. However, it only occurs on Windows systems, and there are no such issues on other systems.

@ysmood
Copy link
Member

ysmood commented Oct 6, 2024

@moxcomic
Copy link

moxcomic commented Oct 6, 2024

Have you checked this?

https://stackoverflow.com/questions/23250505/how-do-i-create-an-executable-from-golang-that-doesnt-open-a-console-window-whe

To be precise, it's not an issue with the parameter itself because I do need to display the terminal. However, when I start a headless browser via Rod, a white, blank window appears. After completing the task and closing the browser, the window disappears. This issue only started recently, and I suspect it's likely due to another update from Chrome that caused this.

@Zisbusy
Copy link

Zisbusy commented Oct 8, 2024

Have you checked this?
https://stackoverflow.com/questions/23250505/how-do-i-create-an-executable-from-golang-that-doesnt-open-a-console-window-whe

To be precise, it's not an issue with the parameter itself because I do need to display the terminal. However, when I start a headless browser via Rod, a white, blank window appears. After completing the task and closing the browser, the window disappears. This issue only started recently, and I suspect it's likely due to another update from Chrome that caused this.

I encountered almost the same problem.

@Q191
Copy link
Author

Q191 commented Oct 26, 2024

issue suddenly disappeared, not sure why

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

4 participants