Tag Archives: webdriver

python to js

Currently working on / investigating:

Python to JS compilers.


Current framwork in Python. Need to test Angular components, yet still couple our current framework without having to switch heavily to JS (Protractor) but still maintain the Webdriver context.

More to follow

Utilizing shift and special characters with send_keys()

Today, had the most surprising blocker today.

Apparently, I’ve been automating for awhile and NEVER have had to send a shift-special-character key (the keys you access by pressing shift + normal keys such as !@#$%^&*() etc.)

[*NOTE — this is NOT the same as Keys characters which are sendable. http://selenium.googlecode.com/svn/trunk/docs/api/py/webdriver/selenium.webdriver.common.keys.html#module-selenium.webdriver.common.keys ]

I found out that you CAN’T send a shift-special character via send_keys. I think this is only a Firefox issue. In any case, after toying around with possible solutions, such as encoding/decoding, etc., here is my workaround.

    "_" : Keys.SUBTRACT,
    "!" : '1',
    '@' : '2',
    '#' : '3',
    '$' : '4',
    '%' : '5',
    '^' : '6',
    '&' : '7',
    '*' : '8',
    '(' : '9'

def send_keys_filtered(driver, value, element):
    for i in range(len(value)):
        character = value[i]
        if character in SHIFT_KEYS:
            a = ActionChains(driver)
            a.key_down(Keys.SHIFT, element)
            a.key_up(Keys.SHIFT, element)

see https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html#typing-keys

In essence, i ActionChain a shift + key if I encounter a shift character.