0
votes

I am trying to select the value from google API. My python version is 2.7. I am scripting for google chrome.

When i start typing something in text box then the text box shows some available values. Like if I type "Del" then it shows the suggestions as Delhi, India.

Now I have scripted till entering text in text field and it is also showing the available values. But as it isn't a dropdown, I can't select the value from that list using name or index. I tried to press down arrow key but using ASCII value as //40 press the value as ( in the text field.

Can anyone please suggest the solution either for selection of value or pressing the down arrow key.

Click element    ${Location_Input}
Press Key    ${Location_Input}    P
sleep    4Seconds
Press Key    ${Location_Input}    \\40

Results in to : "P("

1

1 Answers

0
votes

Press Key ${Location_Input} \\40 does exactly what's written in documentation, i.e. press ASCII character ( represented by code \\40. Check out any ASCII table: http://robotframework.org/Selenium2Library/Selenium2Library.html#Press%20Key

If you want to press non-ASCII key, it becomes bit more difficult. I'd propose write e.g. extended library on top of original Selenium2Library like this:

# ExtendedSelenium.py
from Selenium2Library import Selenium2Library
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys


class ExtendedSelenium(Selenium2Library):

    def __init__(self):
        super(ExtendedSelenium, self).__init__()

    def press_down_arrow(self):
        """ Emulates action "press down arrow on keyboard".
        """
        ActionChains(self._current_browser()).send_keys(Keys.ARROW_DOWN, Keys.NULL).perform()

...and then call it from you RF code:

Library    ExtendedSelenium.py

*** Test Cases ***
Your Test
    ...
    Press Down Arrow
    ...