title: C# Cefsharp unable to getElementsByClassName
body: <p>I am trying to read text from elements by class name in cefsharp. This code from @Jim W does a similar task, only it uses ID instead of class</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
      {
  
          string EvaluateJavaScriptResult;
          var frame = chromeBrowser.GetMainFrame();
          var task = frame.EvaluateScriptAsync("(function() { return document.getElementById('searchInput').value; })();", null);
  
          task.ContinueWith(t =&gt;
          {
              if (!t.IsFaulted)
              {
                  var response = t.Result;
                  EvaluateJavaScriptResult = response.Success ? (response.Result.ToString() ?? "null") : response.Message;
                  MessageBox.Show(EvaluateJavaScriptResult);
              }
          }, TaskScheduler.FromCurrentSynchronizationContext());
  
  
  
  
  
      }
  </code></pre>
  
  <p>Upon changing <code>string EvaluateJavaScriptResult;</code> to <code>obj EvaluateJavaScriptResult;</code> and <code>document.getElementById</code> to <code>document.getElementsByClassName</code>and providing the class name as well as the index, I get error: <code>"Uncaught SyntaxError: missing ) after argument list @:1:53"</code> as the return result. I cannot find where the missing <code>)</code> is and I have tried lots of different placements of <code>(</code> and <code>)</code> in many places and I don't think this is the real error anymore. Everything I have tried has still given me the error @:1:53 (the location?) and I think that means its erroring before it attempts to look for the class name. Does anyone know how I can successfully make cefsharp return the text value of something found by classname?</p>
  
  <p>Edit: upon running a copy and pasted selection of the code I am referencing here, I actually get a different problem, now it just returns null. (This really should just be the same code)</p>
  
  <p>this is the code that returns null</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  using CefSharp;
  using CefSharp.WinForms;
  
  namespace WebAppWorkAround
  {
  public partial class Form1 : Form
  {
      public Form1()
      {
          InitializeComponent();
          InitializeChromium();
      }
      List&lt;string&gt; classList = new List&lt;string&gt;();
      public ChromiumWebBrowser chromeBrowser;
  
      private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
      {
  
      }
  
      private void Form1_Load(object sender, EventArgs e)
      {
  
      }
      private void InitializeChromium()
      {
          CefSettings settings = new CefSettings();
          Cef.Initialize(settings);
          chromeBrowser = new ChromiumWebBrowser("https://en.wikipedia.org/wiki/Main_Page");
          this.panel1.Controls.Add(chromeBrowser);
          chromeBrowser.Dock = DockStyle.Fill;
  
      }
  
      private void Form1_FormClosing(object sender, FormClosingEventArgs e)
      {
          Cef.Shutdown();
      }
      public string extract;
  
      private void button1_Click(object sender, EventArgs e)
      {
  
          object EvaluateJavaScriptResult;
          var frame = chromeBrowser.GetMainFrame();
          var task = frame.EvaluateScriptAsync("(function() { return document.getElementsByClassName('mw-headline')[0].value; })();", null);
  
          task.ContinueWith(t =&gt;
          {
              if (!t.IsFaulted)
              {
                  var response = t.Result;
                  EvaluateJavaScriptResult = response.Success ? (response.Result ?? "null") : response.Message;
                  MessageBox.Show(EvaluateJavaScriptResult.ToString());
              }
          }, TaskScheduler.FromCurrentSynchronizationContext());
  
  
  
  
  
      }
  
  
  }
  }
  </code></pre>