Jump to content

Recommended Posts

Posted

First off, Thank you for hard work on the WebDriver UDF.  I would like to comment on the latest version.  I love Autoit and all that have contributed.  The Function _WD_ElementAction specifically where it was previously used to Send Keyboard keys for example "Enter".  In previous versions a keyboard key like Enter ( "\uE007") could be sent as 

_WD_ElementAction($sSession,$sElement,"value","\uE007")

This would send a keyboard Enter to $sElement.  This works Great.  I do not understand how to do this, _WD_Action($sSession,"actions","\uE007") does Not work.  I realize that I may have to create a Json object to replicate this.  My Solution for now will be to change wd_Core and remove "__WD_EscapeString($sOption)" and replace it with "$sOption"

I always reference back to my "idea of Autoit" and that is to "Simplify windows".  So if WebDriver is to be "W3C" compliant, I would hope that an additional function / option would be created to handle Keyboard Keys.

Here is an Example of what I am commenting on;

=====================================================================================================
Native Autoit Solution;
          Local $hWD=Winactivate("Autoit")
          WinWaitActive($hWD,3)
          Send("{ENTER}")

Old WebDriver Solution;
          _WD_ElementAction($sSession,_WD_FindElement($sSession,"xpath","//*[@id="elSearchField"]"),"value","\uE007")

New WebDriver Solution;
Local $sAction = '{"actions":[{"type": "key", "id": "keyboard_1", "actions": [{"type": "keyDown", "value": "\uE009"}, ' & _
          '{"type": "keyDown", "value": "\uE007"}, {"type": "keyUp", "value": "uE007"}"]}]}'
_WD_Action($sSession, "actions", $sAction)

============================================================================================================

Thank you

RobB

Posted
On 7/23/2026 at 7:31 PM, RobB2 said:

In previous versions a keyboard key like Enter ( "\uE007") could be sent as 

_WD_ElementAction($sSession,$sElement,"value","\uE007")

This particular code hasn't changed in over four years, so you must have been previously using a *really* old version.

Quote

So if WebDriver is to be "W3C" compliant, I would hope that an additional function / option would be created to handle Keyboard Keys.

The above could be read to indicate that the UDF isn't W3C compliant. Was that your intended meaning? If so, please elaborate on how it doesn't comply with the W3C Webdriver specs.

P.S. IIRC, there are multiple examples on this forum for sending keystrokes using _WD_Action.

Posted

Danp2, Originally I thought the change to the code would have been made to be W3c compliant.  After reading the
"WebDriver W3C Working Draft 02 July 2026" I can see that sending keys directly to an element is still a compliant element interaction.  Here is the link, https://www.w3.org/TR/webdriver/#element-send-keys.   And it does work perfectly as long as __WD_EscapeString($sOption) is replaced with $sOption.

Yes, I was using an Old version of the WebDriver udf, but it was not necessary to upgrade until recently.  The newer version has solved the issue of opening Firefox with a default or named profile and that is great, Thank you.   I will search the forum for more _WD_Action examples but, as I noted, the simplicity of sending an Enter to an Element is graceful with much less code.

As to argumentum's comment on using  the cpd.udf.  I would give it a try on a later project but currently I have to stick with the  WebDriver udf's as they are quite extensive and perform well.

I appreciate your timely replies.  I attached a "snippet" or a test function that works perfectly.T.au3

12.5.3 Element Send Keys

HTTP Method URI Template
POST /session/{session id}/element/{element id}/value
Note

The Element Send Keys command scrolls into view the form control element and then sends the provided keys to the element. In case the element is not keyboard-interactable, an element not interactable error is returned.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...