2

please, what is the ASCII code for key "arrow down" and "arrow up" that can be used with keyword "PRESS KEY" in robot framework using selenium2library? I searched many threads, tried many combinations (25, 40, and a lot more) but nothing really simulates the pressing of actual arrow down key..

I need the construction to be working..I need to select a value from a dropdown, but I cannot locate the value to be clicked, so I want to do it by "scrolling" to the value by "arrow down" key...

Press Key    ${locator}    \\ascii code of arrow down

Thank you for helping me, I am really lost now!

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
neliCZka
  • 945
  • 1
  • 16
  • 27
  • 1
    Selenium has a Keys.ARROW_DOWN. Was that an option? Did it work? – Jeremy Kahan Nov 29 '16 at 13:09
  • I know, but I don't know how to combine it - how to use this selenium construction in my robot keywords based on selenium2library.. – neliCZka Nov 29 '16 at 13:12
  • Sorry. I do not know how to help you there. In a similar context I had better luck finding the element on the list using an xpath with its option number. But that was in Protractor. – Jeremy Kahan Nov 29 '16 at 13:21

2 Answers2

1

Try to send the key code to the body or to the targeted element:

Press Key tag=body   \\57365

Or the ASCII code:

Press Key tag=body   \\40

The key codes:

https://github.com/SeleniumHQ/selenium/blob/master/java/client/src/org/openqa/selenium/Keys.java

Florent B.
  • 41,537
  • 7
  • 86
  • 101
  • Hm, it is weird..the first option fails with "ValueError: invalid literal for int() with base 10: 'uE015'" and the second one does nothing. But interesting is that on different element value \\25 seems to work as arrow down. But not for this particualr field, so there must be something else what's wrong. To be honest I am loosing focus on that element all the time, but it seemed to be solved by using "Focus" keyword...anyway, thank you and I'll keep trying – neliCZka Nov 29 '16 at 13:29
  • 25 is the key code for `end of medium`. I don't see why it would behave as the down key. Anyway, the correct code for the down key expected by Selenium is `\\57365` in decimal. – Florent B. Nov 29 '16 at 14:11
  • Instead of using magic numbers, try to use the library's pre-defined vars like `ARROW_DOWN` per https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Press%20Keys – MarkHu Jan 20 '20 at 15:44
1

so my problem was not the arrow in the end but "location" of the actual values in the dropdown..they had totally different locator than the dropdown itself so instead of scrolling I can use click on the element

neliCZka
  • 945
  • 1
  • 16
  • 27