March 12, 2020

Filed under: Automation,Web/Tech — Marcus Tettmar @ 12:56 pm

It may not be immediately obvious that as well as setting the value of elements with ChromeSetElementValue and EdgeSetElementValue you can also send non-character keystrokes, such as Enter, or Page Down.

To do this, use the key codes for Edge and Chrome listed here.

For example:

ChromeSetElementValue>session_id,message_elements_1,First line
//Press enter on the element ... 
ChromeSetElementValue>session_id,message_elements_1,\uE006
ChromeSetElementValue>session_id,message_elements_1,Second line

Note that when sending keystrokes only one can be sent at a time.

Recently someone needed to scroll down inside a div, in order to force the page to fetch more data. Issuing a Page Down on the div element did the trick:

ChromeSetElementValue>session_id,div_elements_1,\uE00F

So, ChromeSetElementValue sends keys as well as sets values – perhaps it should have been called ChromeSendKeysToElement and just maybe we’ll add that as a mapping if it helps.

Of course you don’t have to use the new Chrome/Edge functions – you can still use UI methods and use SetFocus, SendText and/or Image Recognition to locate page elements.

2 Comments »

  1. Renaming ChromeSetElement value to ChromeSendKeysToElement is a great idea.

    Comment by Nick Davison — March 12, 2020 @ 1:19 pm

  2. We wouldn’t want to rename for backward compatibility reasons but we could create a mapping so that both names can be used. But perhaps better would be a new function ChromeSendKeysToElement which can take a list of key codes and/or characters.

    Comment by Marcus Tettmar — March 12, 2020 @ 2:24 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment