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 access and click a button in a slot (shadow-root opened) #1490

Open
patrickToca opened this issue Jul 24, 2024 · 0 comments
Open

How to access and click a button in a slot (shadow-root opened) #1490

patrickToca opened this issue Jul 24, 2024 · 0 comments

Comments

@patrickToca
Copy link

patrickToca commented Jul 24, 2024

What versions are you running?

$ go list -m github.com/chromedp/chromedp
github.com/chromedp/chromedp v0.9.5
$ google-chrome --version
Version 127.0.6533.73 (Official Build) (arm64)
$ go version
go version go1.22.5 darwin/arm64

What did you do? Include clear steps.

I try to click on a button to download a file from this web-page : listed buildings page

if err = chromedp.Run(ctx,
		browser.SetDownloadBehavior(browser.SetDownloadBehaviorBehaviorAllowAndName).
			// remove the code setting up the download directory to simplify the demo
			WithDownloadPath(targetDir).
			WithEventsEnabled(true),
		chromedp.Navigate(urlToVisit),
		chromedp.Sleep(3*time.Second),
		// when it waits too long, chromedp.Poll is better than chromedp.Wait....
		// but can't be used on pagination between pages
		chromedp.WaitVisible(`div.modal-holder`),
		chromedp.Sleep(3*time.Second),
		chromedp.Click(`div.side-panel-ref div:nth-child(3) button.btn`, chromedp.ByQuery),
		// -------- second page ----
		//chromedp.WaitVisible(`arcgis-download-list-card:nth-child(8)`),
		chromedp.Sleep(3*time.Second),
		// `div.side-panel-ref div div.hub-download-list arcgis-download-list #shadow-root div arcgis-download-list-card #shadow-root arcgis-download-list-card-ui arcgis-download-features-button #shadow-root arcgis-download-features-button calcite-button div.button-text`
		chromedp.Click(`arcgis-download-list-card:nth-child(3) arcgis-download-features-button)`, chromedp.ByQuery),
	); err != nil {
		return false, err
	}

The page 1 is running OK.
The page 2 is failing.

Here is an image of the page inspected (hope it makes sense)
Screenshot 2024-07-24 at 11 43 29

What did you expect to see?

The downloading begginning

What did you see instead?

conn.go:128: -> {"id":52,"sessionId":"416F8CE054ABEBA55BE35AA16DC7218E","method":"DOM.querySelector","params":{"nodeId":21,"selector":"arcgis-download-list-card:nth-child(3) arcgis-download-features-button)"}}
conn.go:91: <- {"id":52,"error":{"code":-32000,"message":"DOM Error while querying"},"sessionId":"416F8CE054ABEBA55BE35AA16DC7218E"}
visitWebSite_andDownload.go:29: DOM Error while querying (-32000)

How can I navigate using ChromeDP the slot... elements and click one of them ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant