How to check if element exists in html cefsharp

I tried this but it throws an exception that the response is null
string getElementByName = @"document.getElementsByName(""media"")[0];";
private async void jsgetval(string script)
{
responseResult = "";
JavascriptResponse response = await ytBrowser.EvaluateScriptAsync(script);
responseResult = response.Result.ToString();
Console.WriteLine(responseResult);
}
string getElementByName = @"document.getElementsByName(""media"")[0];";
private async void jsgetval(string script)
{
responseResult = "";
JavascriptResponse response = await ytBrowser.EvaluateScriptAsync(script);
responseResult = response.Result.ToString();
Console.WriteLine(responseResult);
}
7 Replies
Diesel Geezer
Diesel GeezerOP5mo ago
the element does exist tho
x0rld
x0rld5mo ago
and what's the exception ? @Diesel Geezer
Diesel Geezer
Diesel GeezerOP5mo ago
null reference exception @SlashMango
x0rld
x0rld5mo ago
on response.Result I guess ?
Diesel Geezer
Diesel GeezerOP5mo ago
yeah
x0rld
x0rld5mo ago
if you just do the selector without the [0] do you have something ?
Diesel Geezer
Diesel GeezerOP5mo ago
still the same
Want results from more Discord servers?
Add your server