I'm using CefSharp to build a web browser and I'm integrating some javascript on button click, etc.
I am trying to get the element by class name and then save its text to the clipboard.
It successfully finds an element and the text, but I can't set it to the clipboard no matter what.
Here is the code
private void button3_Click(object sender, EventArgs e)
{
CurBrowser.GetMainFrame().ExecuteJavaScriptAsync("var elems1 = document.getElementsByClassName('question-text')");
CurBrowser.GetMainFrame().ExecuteJavaScriptAsync("textt = elems1[elems1.length - 1].innerText");
CurBrowser.GetMainFrame().ExecuteJavaScriptAsync("navigator.clipboard.writeText(textt);");
}
It says that the document is not focused, but I tried to focus it using
textt.focus();
or
elems1.focus():
it returns "textt.focus(); is not a function" or "elems1.focus(): is not a function"