C
C#•4mo ago
Diesel Geezer

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 GeezerOP•4mo ago
the element does exist tho
x0rld 👻 🎃
and what's the exception ? @Diesel Geezer
Diesel Geezer
Diesel GeezerOP•4mo ago
null reference exception @SlashMango
x0rld 👻 🎃
on response.Result I guess ?
Diesel Geezer
Diesel GeezerOP•4mo ago
yeah
x0rld 👻 🎃
if you just do the selector without the [0] do you have something ?
Diesel Geezer
Diesel GeezerOP•4mo ago
still the same
Want results from more Discord servers?
Add your server