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

测试时如何获取当前网页 #1052

Closed
pqj325 opened this issue May 2, 2024 · 5 comments
Closed

测试时如何获取当前网页 #1052

pqj325 opened this issue May 2, 2024 · 5 comments
Labels
needs info The description is not enough to tackle the problem question Questions related to rod

Comments

@pqj325
Copy link

pqj325 commented May 2, 2024

您好,开发时需要直接获取当前网页,请问如何写?当前版本是 v0.115.0

@pqj325 pqj325 added the question Questions related to rod label May 2, 2024
Copy link

github-actions bot commented May 2, 2024

Please add a valid Rod Version: v0.0.0 to your issue. Current version is v0.115.0

generated by check-issue

@ysmood
Copy link
Collaborator

ysmood commented May 5, 2024

什么意思?

@ysmood ysmood added the needs info The description is not enough to tackle the problem label May 5, 2024
@pqj325
Copy link
Author

pqj325 commented May 5, 2024

场景是这样:手工打开一个网页,希望写一段代码实现获取当前网页,并执行代码种的操作,比如点击等。
https://go-rod.github.io/i18n/zh-CN/#/custom-launch?id=%e8%bf%9e%e6%8e%a5%e5%88%b0%e6%ad%a3%e5%9c%a8%e8%bf%90%e8%a1%8c%e7%9a%84%e6%b5%8f%e8%a7%88%e5%99%a8
这里的案例中,需要配置MustPage参数,能否不需要配置这个url就能执行代码,从而获取到当前网页?


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

func main() {
    u := "ws://127.0.0.1:9222/devtools/browser/4dcf09f2-ba2b-463a-8ff5-90d27c6cc913"
    rod.New().ControlURL(u).MustConnect().MustPage("https://example.com")
}```

@ysmood
Copy link
Collaborator

ysmood commented May 5, 2024

我不懂

@pqj325
Copy link
Author

pqj325 commented May 6, 2024

好吧,我先看看文档

@pqj325 pqj325 closed this as completed May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs info The description is not enough to tackle the problem question Questions related to rod
Projects
None yet
Development

No branches or pull requests

2 participants