Rank: Advanced Member Groups: Member
Joined: 8/29/2016 Posts: 64
|
Hello,
Before sending mouse/keyboard events do we need to set focus to WebView that will receive this event?
Or it's multi thread safe and we don't need to worry about switching between WebViews?
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, You can use these methods to send events to the WebView: https://www.essentialobjects.com/doc/eo.webbrowser.webview.sendchar_overloads.aspxhttps://www.essentialobjects.com/doc/eo.webbrowser.webview.sendkeyevent_overloads.aspxhttps://www.essentialobjects.com/doc/eo.webbrowser.webview.sendmouseevent.aspxThese methods themselves do not care about focus. However the script in the page may check where the focus is when they receive keyboard/mouse event. For those you may need to set focus first. However there is no reliable way to ensure a WebView is properly focused since setting focus is asynchronously on the WebView. So usually it's not a good idea to send keyboard/mouse events to the page in order to automate the page. You should use non interactive approach instead --- for example, instead of trying to "click" a button to submit the form, you can call the form's submit method directly. The former is interactive, the later is not. Thanks!
|