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 enable the browser to have two tabs and not open the web properly? #306

Closed
smp12345 opened this issue Dec 11, 2020 · 33 comments
Closed
Assignees
Labels
bug When you are sure about it's a bug

Comments

@smp12345
Copy link

smp12345 commented Dec 11, 2020

Rod Version: v0.84.3
chrome Version: 版本 87.0.4280.88(正式版本)
go Version : go1.14.4 windows/amd64
Windows7

sample code:

package main

import (
	"github.com/go-rod/rod"
	"time"
)

func main() {
	page := rod.New().MustConnect().MustPage("https://www.baidu.com/")
	page.MustWaitLoad().MustScreenshot("a.png")
	time.Sleep(time.Hour)
}

When running the code above, chrome will open two browser window directly, one of the Windows web site: file:///C:/Users/ADMINI~1/AppData/Local/Temp/rod/self-close.html, the other is a blank page, baidu.com is not normal to open

Help me, thank you
1
2

@smp12345 smp12345 added the bug When you are sure about it's a bug label Dec 11, 2020
@ysmood ysmood added the needs info The description is not enough to tackle the problem label Dec 11, 2020
@smp12345
Copy link
Author

I use the sample code of the official website. After opening the browser, two tabs will be opened directly. My computer is Windows 7, and the test on Ubuntu last night is normal, please refer to the screenshot above.What other information do I need to provide?

@ysmood
Copy link
Member

ysmood commented Dec 11, 2020

Works fine with Windows10, sorry I don't know how to reproduce it:

Kapture 2020-12-11 at 10 38 48

@smp12345
Copy link
Author

What's the meaning this path: file:///C:/Users/ADMINI~1/AppData/Local/Temp/rod/self-close.html ?

@smp12345
Copy link
Author

I'm using Chrome 87, which should be up to date

@ysmood
Copy link
Member

ysmood commented Dec 11, 2020

What's the meaning this path: file:///C:/Users/ADMINI~1/AppData/Local/Temp/rod/self-close.html ?

It's the default StartURL, please read the doc:

// New returns the default arguments to start browser.
// Headless will be enabled by default.
// Leakless will be enabled by default.
// UserDataDir will use OS tmp dir by default.
// StartURL will be set to GetSelfClosePage().
func New() *Launcher {

@smp12345
Copy link
Author

I tested ubuntu last night and saw only a TAB, not this one, just go to Baidu.com

@ysmood
Copy link
Member

ysmood commented Dec 11, 2020

Can you try this code?

package main

import (
	"time"

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

func main() {
	u := launcher.New().StartURL("about:blank").MustLaunch()
	page := rod.New().ControlURL(u).MustConnect().MustPage("https://www.baidu.com/")
	page.MustWaitLoad().MustScreenshot("a.png")
	time.Sleep(time.Hour)
}

@smp12345
Copy link
Author

1
2
Open two blank pages, there is no url I sent above

@ysmood
Copy link
Member

ysmood commented Dec 11, 2020

Seems like Chrome crashed, not sure about why is happening. I don't have Window7 to test it, not sure how to help.

@smp12345
Copy link
Author

Can you install a virtual machine and test it out?Thank you very much.After all, Windows 7 still has a large user base

@ysmood
Copy link
Member

ysmood commented Dec 11, 2020

Sure, I just don't have time for it now, I will check when I have time. Thank you for your report!

Can you share more debug info? To enable it is easy just add one line to the .rod file, so your .rod looks like:

show
cdp

Then provide your console log to us.

@smp12345
Copy link
Author

smp12345 commented Dec 11, 2020

[cdp] 2020/12/11 10:04:58 => #1 @00000000 Target.setDiscoverTargets {"discover":true}
[cdp] 2020/12/11 10:04:58 <- @00000000 Target.targetCreated {"targetInfo":{"targetId":"3936a2bf-04ab-4052-9336-89db1e265db4","type":"browser","title":"","url":"","attached":true,"canAc
cessOpener":false}}
[cdp] 2020/12/11 10:04:58 <= #1 {}
[cdp] 2020/12/11 10:04:58 => #2 @00000000 Browser.getVersion {}
[cdp] 2020/12/11 10:04:58 <= #2 {"protocolVersion":"1.3","product":"Chrome/88.0.4298.0","revision":"@e62cb7e3fc7c40548cef66cdf19d270535d9350b","userAgent":"Mozilla/5.0 (Windows NT 6.1;
 WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4298.0 Safari/537.36","jsVersion":"8.8.134"}
[cdp] 2020/12/11 10:04:58 => #3 @00000000 Target.createTarget {"url":"about:blank"}
[cdp] 2020/12/11 10:04:58 <- @00000000 Target.targetCreated {"targetInfo":{"targetId":"4D311CABDF463EE3798C316448037D21","type":"page","title":"","url":"about:blank","attached":false,"
canAccessOpener":false,"browserContextId":"A23D0D2DD4592241D0596610C745276F"}}
[cdp] 2020/12/11 10:04:58 <= #3 {"targetId":"4D311CABDF463EE3798C316448037D21"}
[cdp] 2020/12/11 10:04:58 => #4 @00000000 Target.attachToTarget {"targetId":"4D311CABDF463EE3798C316448037D21","flatten":true}
[cdp] 2020/12/11 10:04:58 <- @00000000 Target.targetCrashed {"targetId":"4D311CABDF463EE3798C316448037D21","status":"failed to launch","errorCode":18}
[cdp] 2020/12/11 10:04:58 <- @00000000 Target.targetInfoChanged {"targetInfo":{"targetId":"4D311CABDF463EE3798C316448037D21","type":"page","title":"","url":"about:blank","attached":tru
e,"canAccessOpener":false,"browserContextId":"A23D0D2DD4592241D0596610C745276F"}}
[cdp] 2020/12/11 10:04:58 <- @00000000 Target.attachedToTarget {"sessionId":"D95252CF92D83220F0FD15D0207F3177","targetInfo":{"targetId":"4D311CABDF463EE3798C316448037D21","type":"page"
,"title":"","url":"about:blank","attached":true,"canAccessOpener":false,"browserContextId":"A23D0D2DD4592241D0596610C745276F"},"waitingForDebugger":false}
[cdp] 2020/12/11 10:04:58 <= #4 {"sessionId":"D95252CF92D83220F0FD15D0207F3177"}
[cdp] 2020/12/11 10:04:58 => #5 @D95252CF Page.enable {}

@ysmood
Copy link
Member

ysmood commented Dec 11, 2020

Seems like an upstream Chrome bug. Can you run this:

package main

import (
	"time"

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

func main() {
	u := launcher.NewUserMode().MustLaunch()
	page := rod.New().ControlURL(u).MustConnect().MustPage("https://www.baidu.com/")
	page.MustWaitLoad().MustScreenshot("a.png")
	time.Sleep(time.Hour)
}

@smp12345
Copy link
Author

3
There is only one blank page after loading

@smp12345
Copy link
Author

There are two blank pages first, and then a blank page is automatically closed

@smp12345
Copy link
Author

I tested it on another win7 and had exactly the same problem.

@smp12345
Copy link
Author

[cdp] 2020/12/11 10:15:38 => #1 @00000000 Target.setDiscoverTargets {"discover":true}
[cdp] 2020/12/11 10:15:38 <- @00000000 Target.targetCreated {"targetInfo":{"targetId":"6BDCBC362A05C18BEAA41C74A54465BA","type":"page","title":"about:blank","url":"about:blank","attach
ed":false,"canAccessOpener":false,"browserContextId":"F0B2995C213DC8CD63BEB49FBB634899"}}
[cdp] 2020/12/11 10:15:38 <- @00000000 Target.targetCreated {"targetInfo":{"targetId":"77324c01-a277-4a70-a930-75a430687c9a","type":"browser","title":"","url":"","attached":true,"canAc
cessOpener":false}}
[cdp] 2020/12/11 10:15:38 <= #1 {}
[cdp] 2020/12/11 10:15:38 => #2 @00000000 Browser.getVersion {}
[cdp] 2020/12/11 10:15:38 <= #2 {"protocolVersion":"1.3","product":"Chrome/88.0.4298.0","revision":"@e62cb7e3fc7c40548cef66cdf19d270535d9350b","userAgent":"Mozilla/5.0 (Windows NT 6.1;
WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4298.0 Safari/537.36","jsVersion":"8.8.134"}
[cdp] 2020/12/11 10:15:38 => #3 @00000000 Target.createTarget {"url":"about:blank"}
[cdp] 2020/12/11 10:15:38 <- @00000000 Target.targetCreated {"targetInfo":{"targetId":"6DEE2AE6437F6117745FA0BAE58E520E","type":"page","title":"","url":"about:blank","attached":false,"
canAccessOpener":false,"browserContextId":"F0B2995C213DC8CD63BEB49FBB634899"}}
[cdp] 2020/12/11 10:15:38 <= #3 {"targetId":"6DEE2AE6437F6117745FA0BAE58E520E"}
[cdp] 2020/12/11 10:15:38 <- @00000000 Target.targetInfoChanged {"targetInfo":{"targetId":"6DEE2AE6437F6117745FA0BAE58E520E","type":"page","title":"about:blank","url":"about:blank","at
tached":false,"canAccessOpener":false,"browserContextId":"F0B2995C213DC8CD63BEB49FBB634899"}}
[cdp] 2020/12/11 10:15:38 => #4 @00000000 Target.attachToTarget {"targetId":"6DEE2AE6437F6117745FA0BAE58E520E","flatten":true}
[cdp] 2020/12/11 10:15:38 <- @00000000 Target.targetInfoChanged {"targetInfo":{"targetId":"6DEE2AE6437F6117745FA0BAE58E520E","type":"page","title":"about:blank","url":"about:blank","at
tached":true,"canAccessOpener":false,"browserContextId":"F0B2995C213DC8CD63BEB49FBB634899"}}
[cdp] 2020/12/11 10:15:38 <- @00000000 Target.attachedToTarget {"sessionId":"08B25FD9ABEE6B094F3B60E02060BA9A","targetInfo":{"targetId":"6DEE2AE6437F6117745FA0BAE58E520E","type":"page"
,"title":"about:blank","url":"about:blank","attached":true,"canAccessOpener":false,"browserContextId":"F0B2995C213DC8CD63BEB49FBB634899"},"waitingForDebugger":false}
[cdp] 2020/12/11 10:15:38 <= #4 {"sessionId":"08B25FD9ABEE6B094F3B60E02060BA9A"}
[cdp] 2020/12/11 10:15:38 => #5 @08B25FD9 Page.enable {}
[cdp] 2020/12/11 10:15:38 <= #5 {}
[cdp] 2020/12/11 10:15:38 => #6 @08B25FD9 DOM.enable {}
[cdp] 2020/12/11 10:15:38 <= #6 {}
[cdp] 2020/12/11 10:15:38 => #7 @08B25FD9 Runtime.evaluate {"expression":"window"}
[cdp] 2020/12/11 10:15:38 <= #7 {"result":{"type":"object","className":"Window","description":"Window","objectId":"-3064364799009828676.1.1"}}
panic: invalid character '.' after top-level value

@ysmood
Copy link
Member

ysmood commented Dec 11, 2020

Can you kill all Chrome processes then try my last code again?

@smp12345
Copy link
Author

4
I killed all the Chrome processes, but it's the same problem

@ysmood
Copy link
Member

ysmood commented Dec 11, 2020

Does headless mode work?

@smp12345
Copy link
Author

It also doesn't work properly and doesn't see the PNG file

@smp12345
Copy link
Author

[cdp] 2020/12/11 10:28:06 => #1 @00000000 Target.setDiscoverTargets {"discover":true}
[cdp] 2020/12/11 10:28:06 <- @00000000 Target.targetCreated {"targetInfo":{"targetId":"B39B5B2457C6E8FC18E02CEB663AAF9F","type":"page","title":"","url":"file:///C:/Users/ADMINI~1/AppDa
ta/Local/Temp/rod/self-close.html","attached":false,"canAccessOpener":false,"browserContextId":"C2446520E703393410B76B87E136941F"}}
[cdp] 2020/12/11 10:28:06 <- @00000000 Target.targetCreated {"targetInfo":{"targetId":"d16a7d51-ff3f-480c-a7ba-c7d9c0a1deec","type":"browser","title":"","url":"","attached":true,"canAc
cessOpener":false}}
[cdp] 2020/12/11 10:28:06 <= #1 {}
[cdp] 2020/12/11 10:28:06 => #2 @00000000 Browser.getVersion {}
[cdp] 2020/12/11 10:28:06 <= #2 {"protocolVersion":"1.3","product":"Chrome/88.0.4298.0","revision":"@e62cb7e3fc7c40548cef66cdf19d270535d9350b","userAgent":"Mozilla/5.0 (Windows NT 6.1;
WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4298.0 Safari/537.36","jsVersion":"8.8.134"}
[cdp] 2020/12/11 10:28:06 => #3 @00000000 Target.createTarget {"url":"about:blank"}
[cdp] 2020/12/11 10:28:06 <- @00000000 Target.targetCreated {"targetInfo":{"targetId":"48E7A8EB93808473088525BE454C0FD2","type":"page","title":"","url":"about:blank","attached":false,"
canAccessOpener":false,"browserContextId":"C2446520E703393410B76B87E136941F"}}
[cdp] 2020/12/11 10:28:07 <= #3 {"targetId":"48E7A8EB93808473088525BE454C0FD2"}
[cdp] 2020/12/11 10:28:07 => #4 @00000000 Target.attachToTarget {"targetId":"48E7A8EB93808473088525BE454C0FD2","flatten":true}
[cdp] 2020/12/11 10:28:07 <- @00000000 Target.targetInfoChanged {"targetInfo":{"targetId":"48E7A8EB93808473088525BE454C0FD2","type":"page","title":"","url":"about:blank","attached":tru
e,"canAccessOpener":false,"browserContextId":"C2446520E703393410B76B87E136941F"}}
[cdp] 2020/12/11 10:28:07 <- @00000000 Target.attachedToTarget {"sessionId":"23DC35CEC9FC7963C3E0FE7B5EE67DB8","targetInfo":{"targetId":"48E7A8EB93808473088525BE454C0FD2","type":"page"
,"title":"","url":"about:blank","attached":true,"canAccessOpener":false,"browserContextId":"C2446520E703393410B76B87E136941F"},"waitingForDebugger":false}
[cdp] 2020/12/11 10:28:07 <= #4 {"sessionId":"23DC35CEC9FC7963C3E0FE7B5EE67DB8"}
[cdp] 2020/12/11 10:28:07 => #5 @23DC35CE Page.enable {}
[cdp] 2020/12/11 10:28:07 <- @00000000 Target.targetInfoChanged {"targetInfo":{"targetId":"48E7A8EB93808473088525BE454C0FD2","type":"page","title":"about:blank","url":"about:blank","at
tached":true,"canAccessOpener":false,"browserContextId":"C2446520E703393410B76B87E136941F"}}
[cdp] 2020/12/11 10:28:07 <= #5 {}
[cdp] 2020/12/11 10:28:07 => #6 @23DC35CE DOM.enable {}
[cdp] 2020/12/11 10:28:07 <= #6 {}
[cdp] 2020/12/11 10:28:07 => #7 @23DC35CE Runtime.evaluate {"expression":"window"}
[cdp] 2020/12/11 10:28:07 <= #7 {"result":{"type":"object","className":"Window","description":"Window","objectId":"-5356785989425377739.1.1"}}
panic: invalid character '.' after top-level value

@ysmood
Copy link
Member

ysmood commented Dec 11, 2020

Thank you, I think it's enough now, we will test Win7 later. I missed this OS because seldom developers nowadays still use Win7.

@NormalPunch is checking Win7.

@ysmood ysmood removed the needs info The description is not enough to tackle the problem label Dec 11, 2020
@smp12345
Copy link
Author

Thank you. This is my first time using this framework, and I feel the documentation is excellent.I used Chromedp before, and it worked fine, but It didn't feel stable enough to fail when I clicked on an element multiple times

@smp12345
Copy link
Author

Although the development of people using Win7 is not much, but the user use Win7 or a lot of my customers are Win7, Win7 this system or do not give up, thank you

@ysmood ysmood assigned ysmood and unassigned NormalPunch Dec 12, 2020
@ysmood ysmood closed this as completed in 7032dd6 Dec 12, 2020
@ysmood
Copy link
Member

ysmood commented Dec 12, 2020

Published the v0.85.0, should be fixed.

@smp12345
Copy link
Author

Thank you very much

@smp12345
Copy link
Author

@ysmood After your repair, the Baidu website can be normally opened, but there is an extra blank page. How to remove this blank page
Uploading 2.JPG…

@ysmood
Copy link
Member

ysmood commented Dec 14, 2020

@smp12345 Don't remove it, the reason is the last line of here: https://pkg.go.dev/github.com/go-rod/rod@v0.85.4/lib/launcher#New

@smp12345
Copy link
Author

I see what you mean, but in this case, the user experience is not very good. Can We use the MustPage url as an active page?

@smp12345
Copy link
Author

I mainly use this framework for automation, it would be better to automate the interface, I need to see the process of execution, but there is an extra blank page, it doesn't look comfortable @ysmood

@ysmood
Copy link
Member

ysmood commented Dec 14, 2020

This commit should have fixed your issue 475b659

Please check v0.85.6

@smp12345
Copy link
Author

That's OK. Thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug When you are sure about it's a bug
Projects
None yet
Development

No branches or pull requests

3 participants