GithubHelp home page GithubHelp logo

stuck in a `chrome://` page about rod HOT 8 CLOSED

go-rod avatar go-rod commented on July 18, 2024
stuck in a `chrome://` page

from rod.

Comments (8)

ysmood avatar ysmood commented on July 18, 2024 1

Well if you want to be lazy, use this:

Screen Shot 2020-06-09 at 22 38 27

To reduce pain:

document.querySelector("body > settings-ui").shadowRoot.querySelector("#main").shadowRoot.querySelector("settings-basic-page").shadowRoot.querySelector("#basicPage > settings-section:nth-child(7) > settings-privacy-page").shadowRoot.querySelector("#clearBrowsingData").shadowRoot.querySelector("#label")

from rod.

ysmood avatar ysmood commented on July 18, 2024

fixed some bugs recently, please try the latest version

from rod.

NormalPunch avatar NormalPunch commented on July 18, 2024

fixed some bugs recently, please try the latest version

Yes, rod in my go.mod was the latest version.

	github.com/ysmood/rod v0.37.0

from rod.

ysmood avatar ysmood commented on July 18, 2024

If you try document.querySelector("#clearBrowsingData") it will return null.
When you debug please use Trace(true):

rod.New().ControlURL(u).Trace(true).Connect()

It will tell you what rod is doing, this time it's retrying to get something that it can't get.

Screen Shot 2020-06-09 at 22 13 41

The reason is this page is using shadow-dom. You have to use something like this:

	clearBrowsingData := page.Element("settings-ui").ShadowRoot().
		Element("#main").ShadowRoot().
		Element("settings-basic-page").ShadowRoot().
		Element("settings-privacy-page").ShadowRoot().
		Element("#clearBrowsingData")

It's like the iframe, I'm thinking of a way to make it easier but it will take some time.

from rod.

ysmood avatar ysmood commented on July 18, 2024

😂 Man, you don't have to do this kind of crazy thing, Rod has browser.Incognito() to create isolated env.

from rod.

NormalPunch avatar NormalPunch commented on July 18, 2024

If you try document.querySelector("#clearBrowsingData") it will return null.
When you debug please use Trace(true):

rod.New().ControlURL(u).Trace(true).Connect()

It will tell you what rod is doing, this time it's retrying to get something that it can't get.

Screen Shot 2020-06-09 at 22 13 41

The reason is this page is using shadow-dom. You have to use something like this:

	clearBrowsingData := page.Element("settings-ui").ShadowRoot().
		Element("#main").ShadowRoot().
		Element("settings-basic-page").ShadowRoot().
		Element("settings-privacy-page").ShadowRoot().
		Element("#clearBrowsingData")

It's like the iframe, I'm thinking of a way to make it easier but it will take some time.

Trace is cool, thx

from rod.

NormalPunch avatar NormalPunch commented on July 18, 2024

😂 Man, you don't have to do this kind of crazy thing, Rod has browser.Incognito() to create isolated env.

Yean but too much costs for restarting a browser. And sometimes incognito will be detected.

And it seems that cdp api cannot clear all domains.

from rod.

NormalPunch avatar NormalPunch commented on July 18, 2024

Cool, solved, thanks @ysmood

from rod.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.