sendKeys--${KEY_ENTER}


#1

I have an input element in my page, I wanna press enter to display an animation.But I cann’t get the keycode when I use sendKeys command.

{
“Command”: “type”,
“Target”: “id=sign-input”,
“Value”: “aaa”
},
{
“Command”: “sendKeys”,
“Target”: “id=sign-input”,
“Value”: “${KEY_ENTER}”
},


#2

${KEY_ENTER} works with most “normal” websites. Below is a working example with the DuckDuckGo search engine. But complex Javascript on a website can sometimes “swallow” the simulated key event. => For a test, can you link to the web page that you are trying to automate?

{
  "CreationDate": "2018-9-11",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://duckduckgo.com/",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "id=search_form_input_homepage",
      "Value": "solar cells"
    },
    {
      "Command": "sendKeys",
      "Target": "id=search_form_input_homepage",
      "Value": "${KEY_ENTER}"
    }
  ]
}

#3

Your example that it can work when I had tested . But I cann’t get the keycode in my simple demo.Please help me to resolve the issue,thanks!


#4

Actually I’m hitting the same issue.
I don’t know why it is working on “https://duckduckgo.com/”, but the event object sent by “sendkeys” does not have the “code” field or the “key” field.
Here is an example of the event object “sendkeys” is sending:

1. bubbles:true
2. cancelBubble:false
3. cancelable:true
4. composed:false
5. currentTarget:null
6. defaultPrevented:false
7. eventPhase:0
8. isTrusted:false
9. path:(5) [input#search_form_input_homepage.js-search-input.search__input--adv, body, html, document, Window]
10. returnValue:true
11. srcElement:input#search_form_input_homepage.js-search-input.search__input--adv
12. target:input#search_form_input_homepage.js-search-input.search__input--adv
13. timeStamp:2578.700000070967
14. type:"keydown"
15. __proto__:Event

while, a normal keydown event object should be like:

  1. altKey:false
  2. bubbles:true
  3. cancelBubble:false
  4. cancelable:true
  5. charCode:0
  6. code:“Enter”
  7. composed:true
  8. ctrlKey:false
  9. currentTarget:null
  10. defaultPrevented:false
  11. detail:0
  12. eventPhase:0
  13. isComposing:false
  14. isTrusted:true
  15. key:“Enter”
  16. keyCode:13
  17. location:0
  18. metaKey:false
  19. path:(5) [input#search_form_input_homepage.js-search-input.search__input–adv, body, html, document, Window]
  20. repeat:false
  21. returnValue:true
  22. shiftKey:false

The most common way for listening a “enter” event would be checking the “key” or “code” field.

could you help me figure it out?


#5

Our problem is just the opposite: We need a website (or websites) where it does not work, so that we can test. The issue we have during sendkey development is that we find even if we make the above changes it would not improve the command. We might be wrong here.

=> That is why it will be very helpful if you (or anyone else reading this) can reply with websites where the sendkey ${KEY_ENTER} does not work currently. Then we can use these pages to test and debug further.