Replies: 2 comments 2 replies
-
|
Beta Was this translation helpful? Give feedback.
-
Yes it's possible. The how would depend on the details. Here are some generic options to get you started. Option 1: https://github.com/cefsharp/CefSharp/wiki/Frequently-asked-questions#13-how-do-you-handle-a-javascript-event-in-c Option 2: Excerpt from https://github.com/cefsharp/CefSharp.Dom#dom-access await using var devToolsContext = await chromiumWebBrowser.CreateDevToolsContextAsync();
//Event Handler
//Expose a function to javascript, functions persist across navigations
//So only need to do this once
await devToolsContext.ExposeFunctionAsync("jsAlertButtonClick", () =>
{
_ = devToolsContext.EvaluateExpressionAsync("window.alert('Hello! You invoked window.alert()');");
});
var jsAlertButton = await devToolsContext.QuerySelectorAsync<HtmlButtonElement>("#jsAlertButton");
//Write up the click event listener to call our exposed function
_ = jsAlertButton.AddEventListenerAsync("click", "jsAlertButtonClick");
|
Beta Was this translation helpful? Give feedback.
-
Hi, is there a way to get the HTML element under the cursor or on a click?
The idea is to write a data extraction tool, that could be set to automatically read data (capture) from a website. To set things up a user would need to click the items to read data from. Afterwards a automatic script would use that data to select the objects again and read the data anew. - Is that possible?
Beta Was this translation helpful? Give feedback.
All reactions