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

点击一个按钮后js向页面写入了一段html代码,如何获取这个元素 #839

Closed
zk3151463 opened this issue Mar 20, 2023 · 6 comments
Labels
needs info The description is not enough to tackle the problem question Questions related to rod

Comments

@zk3151463
Copy link

点击一个按钮后js向页面写入了一段html代码,如何获取这个元素

@zk3151463 zk3151463 added the question Questions related to rod label Mar 20, 2023
@rod-robot
Copy link

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

Please fix the format of your markdown:

1:33 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1]

generated by check-issue

@ysmood
Copy link
Collaborator

ysmood commented Mar 21, 2023

抱歉没看懂

@ysmood ysmood added the needs info The description is not enough to tackle the problem label Mar 21, 2023
@zk3151463
Copy link
Author

比如说我操作一个登陆页面,点击登录后它弹出一个弹窗,如何获取这个弹窗,我用文档里方法一直没有成功

@ysmood
Copy link
Collaborator

ysmood commented Mar 21, 2023

请提供可以复现问题的代码

@zk3151463
Copy link
Author

package main

import (
"fmt"
"time"

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

)

func main() {
// Getbrewdir()
path, _ := launcher.LookPath()
u := launcher.New().Set("cleanup").Bin(path).Headless(false).MustLaunch()

page := rod.New().ControlURL(u).Timeout(time.Minute).MustConnect()

page1 := page.MustPage("https://login.taobao.com/member/login.jhtml?style=mini&newMini2=true&redirectURL=https://myseller.taobao.com/home.htm/QnworkbenchHome/")

el := page1.MustElement(`#fm-login-id`)
el.MustInput("33333") //账户
el1 := page1.MustElement(`#fm-login-password`)
el1.MustInput("12121212") //密码

// 左击
btn := page1.MustElement(`[type=submit]`)
btn.MustClick()
// 等待浏览器处理新内容
page1.MustWaitRequestIdle()
// isdl := page1.MustHas("#nc_1_n1z")
page2, _ := page.Pages()

page1 = page.MustPages()[0]
ishua := page2[0].MustHas("#nc_1_n1z")
fmt.Println(ishua)

if ishua {
	slider := page1.MustElement("#nc_1_n1z")
	fmt.Println(page1.MustElement("#nc_1_n1z").MustHTML())
	fmt.Println(222)
	fmt.Println(slider.MustShape().Box().Y)
}

fmt.Println("11", *page1.MustCookies()[0])
time.Sleep(time.Hour)

}

@ysmood
Copy link
Collaborator

ysmood commented Mar 22, 2023

请仔细读读这个 #322

@ysmood ysmood closed this as completed Mar 22, 2023
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

3 participants