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

Cannot click continue #1111

Open
lyy077 opened this issue Sep 6, 2024 · 1 comment
Open

Cannot click continue #1111

lyy077 opened this issue Sep 6, 2024 · 1 comment
Labels
question Questions related to rod

Comments

@lyy077
Copy link

lyy077 commented Sep 6, 2024

Rod Version: v0.116.2

The code to demonstrate your question

func Test() {
	u := launcher.New().HeadlessNew(false).MustLaunch()
	browser := rod.New().ControlURL(u).MustConnect()
	page := browser.MustPage("")
	
	defer browser.MustClose()

	var e proto.NetworkResponseReceived
	wait := page.WaitEvent(&e)
	page.MustNavigate("https://www.offers-pick.com/sports-outdoors/sleeping-bags")
	wait()

	originTab := page

	// 等待页面稳定
	page.MustWaitStable()
	elements, _ := page.ElementsX("//div[@class='product-list']//div[text() = ' CHECK PRICE ']")
	for _, element := range elements {
		element.MustClick()
		time.Sleep(time.Second * 1)
		browser.MustSetCookies()
		originTab.MustActivate()
		time.Sleep(time.Second * 2)
	}
	time.Sleep(time.Minute * 30)
}

go-rod Click on several elements. After clicking on an element, a new tab is opened. Switch back to the original tab and you can't click any further. The program is stuck.

@lyy077 lyy077 added the question Questions related to rod label Sep 6, 2024
@ysmood
Copy link
Member

ysmood commented Sep 7, 2024

originTab is not the original tab, if you want to create 2 tabs, you should use Browser.MustPage or WaitOpen, etc.

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