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

Find XPath from ElementHandle/JSHandle #332

Open
unknownsoldier08 opened this issue Feb 26, 2023 · 0 comments
Open

Find XPath from ElementHandle/JSHandle #332

unknownsoldier08 opened this issue Feb 26, 2023 · 0 comments

Comments

@unknownsoldier08
Copy link

Hey guys, just wondering if it's possible to get a selected elements XPath with the playwright-go implementation?

I've tried to see if I can build the XPath myself, by reading up the parentElement in a node using the EvaluateHandle function on an ElementHandle. However, it seems to panic with the following error;

panic: interface conversion: interface {} is *playwright.elementHandleImpl, not *playwright.jsHandleImpl

func findXPath(handle playwright.ElementHandle) string {
  eval, _ := handle.EvaluateHandle(`(element) => element.parentElement`, handle)
  return eval.String()
}

Thanks for your help

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