Tab to recaptcha

前端 未结 2 1938
滥情空心
滥情空心 2021-01-27 15:17

Here\'s the scenario:

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

2条回答
  •  梦毁少年i
    2021-01-27 16:02

    I found a solution that avoided SendKeys and javascript entirely. The CefSharp browser has the ability to simulate key presses and mouse clicks. I ended up just selecting the textbox that preceded the captcha and then tabbing to it.

    chromeBrowser.Focus();
    chromeBrowser.ExecuteScriptAsync("document.getElementsByClassName('txtBox')[0].focus();");
    
    CefSharp.KeyEvent keyEvent = new CefSharp.KeyEvent();
    keyEvent.WindowsKeyCode = (int)Keys.Tab;
    chromeBrowser.GetBrowser().GetHost().SendKeyEvent(keyEvent);
    

提交回复
热议问题