playwright-go
playwright-go copied to clipboard
Find XPath from ElementHandle/JSHandle
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