Skip to content
This repository has been archived by the owner on Jun 28, 2023. It is now read-only.

Find element based on Javascript selector. #195

Open
dglsparsons opened this issue Oct 10, 2019 · 0 comments
Open

Find element based on Javascript selector. #195

dglsparsons opened this issue Oct 10, 2019 · 0 comments

Comments

@dglsparsons
Copy link

Hi,

We use shadowDOM fairly extensively in our codebase, and wanted to automate a suite of tests using agouti. However - I'm hitting a major blocker accessing any DOM elements within the shadow root on the page.

It's not part of the webdriver spec, so not that surprising that there's no built in behaviour for this - the common workaround seems to be running custom javascript to explore the DOM / find elements.

E.G

document.querySelector("some-element").shadowRoot.querySelector("target-element")

I've tried doing this through the RunScript API -

Eventually(func() string {
	var result string
	p.RunScript(
		`return document.querySelector("some-element").shadowRoot.querySelector("target-element"),
		nil,
		&result,
	)
	return result
}).Should(Equal("wat"))

However, it seems to return nothing, and i can't find any way of getting an *agouti.Selection out of the javascript return.

Is there any way to achieve this?

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

No branches or pull requests

1 participant