title: Tab to recaptcha
body: <p>Here's the scenario:</p>
  
  <p>I'm loading a page via a CefSharp browser. When the user clicks a certain button (on the form, not the web page) the page should then focus on the recaptcha.</p>
  
  <p>I've tried using SendKeys to tab to the captcha, but instead of the tab being pressed once it seems to register multiple times and ends up focusing on the 'Terms' link in the bottom right of the captcha instead of the checkbox.</p>
  
  <p>I've also tried using the chromeBrowser.ExecuteScriptAsync() method to run javascript on the page. I can successfully focus on textboxes and even run keypress events from those textboxes, but when I run a tab keypress event on the preceding textbox the recaptcha is still not highlighted.</p>
  
  <pre><code>chromeBrowser.Focus();
  chromeBrowser.ExecuteScriptAsync("document.getElementsByClassName('txtBox')[0].Focus();" +
  "document.getElementsByClassName('txtBox')[0].value = 'test string';")
  SendKeys.Send("{TAB}");
  SendKeys.Send("{ENTER}");
  </code></pre>
  
  <p>I've also added an event listener that confirms that the Tab is indeed being 'pressed'</p>
  
  <pre><code>chromeBrowser.Focus();
  chromeBrowser.ExecuteScriptAsync("document.getElementsByClassName('txtBox')[0].addEventListener('keypress', function(){" +
  "alert('something was pressed!');});" +
  "document.getElementsByClassName('txtBox')[0].focus();" +
  "document.getElementsByClassName('txtBox')[0].value = 'test value';" +
  "var e = document.createEvent('KeyboardEvent');" +
  "e.initKeyboardEvent('keypress', true, true, document.defaultView, 9, 0, '', false, '');" +
  "document.getElementsByClassName('txtBox')[0].dispatchEvent(e);");
  </code></pre>
  
  <p>I've tried getElementsByClassName for every classname that shows on the recapctha in a page inspect and then setting focus to that. I've tried getElementById on the ID of the recaptcha iFrame and setting focus to that. Nothing focuses on the captcha.</p>
  
  <p>I'm out of ideas. Any help would be appreciated.</p>