2

I know there is an action class where this is possible, but I just understand common keys, such as: enter, backspace, and tab. For instance:

action.sendKeys (Keys.ENTER).perform();

For modifier keys---Caps Lock, Control, Option, Command---it is not very clear how to use sendKeys?

1

This link might be help you out:

Based on that, you can create a function, which can simulate caps lock ON e.g.

(just a rough function)

def send_caps_keys(keys):
  for key in keys:
    element.send_keys [:shift, key]
1

Here's a list of the keys you can send.

  • Thank you for your timely reply, but I can not find specific examples. I was just learning the selenium, can you give me an example? How simulate keystrokes Caps Lock key? such as pressing the enter key: action.sendKeys (Keys.ENTER). perform (); – Devin Chen Aug 28 '13 at 16:39
0

Maybe this will help get you started. You can hack in a caps lock key into selenium/webdriver/common/keys.py In the Keys class I added the following line:

CAPS         = '\ue21EA'

Then I fired up webdriver and pointed it at a JavaScript Caps Lock detector

I found the element and sent it the CAPS key. Then the webpage returned a caps lock warning

x = driver.find_element_by_name('password')
x.send_keys(Keys.Keys.CAPS)

If your goal is checking whether caps lock is on or off, this should help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.