jvppeteer
jvppeteer copied to clipboard
Best way to get innerText of an element
What is the best way to get text inside an HTML element like a span.
I am using below. Is that the best option?
Object value = elementHandle.evaluate("x => x.innerText", Collections.emptyList());
This is the way to value in Java:
public static String getElementAttr(ElementHandle element, String param) { try { JSHandle jsHandle = element.getProperty(param); if (null == jsHandle) return ""; return jsHandle.jsonValue().toString(); } catch (Exception e) { return ""; } }
Thanks @MaxBill. Do you know the difference between your approach and mine in terms of performance? Which one is faster?