Skip to content

Instantly share code, notes, and snippets.

@amaitland
Last active November 14, 2022 17:17
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save amaitland/9d354376960b0cd9305a to your computer and use it in GitHub Desktop.
Save amaitland/9d354376960b0cd9305a to your computer and use it in GitHub Desktop.
browser.LoadingStateChanged += OnLoadingStateChanged;
//A very basic example
private void OnLoadingStateChanged(object sender, LoadingStateChangedEventArgs args)
{
//Wait for the Page to finish loading
if (args.IsLoading == false)
{
//Reccomended to use an anon closure
const string script = @"(function()
{
return 1 + 1;
})();";
browser.EvaluateScriptAsync(script).ContinueWith(x =>
{
var response = x.Result;
if (response.Success && response.Result != null)
{
var onePlusOne = (int)response.Result;
//Do something here (To interact with the UI you must call BeginInvoke)
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment