Selenium Basic Keyboard method

Source: Internet
Author: User
Tags delete key

Don't want to work overtime tonight, so hurry back to see the book:

1. Under the Selenium gadget: Firebug/firepath.

2. Determined the reading order, I think the difficulty starts relatively good, so I still first look at the Python-based selenium, another book to see, think of their ability or too weak, or from the friendly first, although before also saw some of the usage of by_id, but really actually do the weak chicken one.

3. Learned the Selenium keyboard event simulation, in fact, before this has been open for a long time the virtual machine opened once. I can't even remember the man, my heart is very tired.

Let's go back to the point and learn something and say it. Or the API that calls the keyboard, I'm going to say it first.

Send_keys (keys.back_space) Delete key

In the middle of a sentence, today the size of my gray head vinegar, changed several times the script to run up.

Send_keys (keys.space) space key

Send_keys (keys.tab) Tab key

Send_keys (keys.espace) fallback key

Send_keys (keys.enter) Enter

Send_keys (Keys.control, ' a ') Select all

Send_keys (Keys.control, ' C ') copy

Send_keys(Keys.control, ' x ') cut

Send_keys (Keys.control, ' V ') paste

Send_keys (KEYS.F1) F1


Personally think the keyboard event is quite practical, if you are familiar with the keyboard operation, you can do a lot of things, very convenient, the following is my code, basically the above are used again.

    1. From Selenium import Webdriver
    2. From Selenium.webdriver.common.action_chains import actionchains
    3. From Selenium.webdriver.common.keys import keys
    4. Driver=webdriver. Firefox ()
    5. Driver.get ("http://www.baidu.com")
    6. driver.find_element_by_id ("kw"). Send_keys ("seleniumm")
    7. driver.find_element_by_id ("kw"). Send_keys (Keys.back_space)
    8. driver.find_element_by_id ("kw"). Send_keys (Keys.space)
    9. driver.find_element_by_id ("kw"). Send_keys ("tutorial")
    10. driver.find_element_by_id ("kw"). Send_keys (Keys.control,' a ')
    11. driver.find_element_by_id ("kw"). Send_keys (Keys.control,' x ')
    12. driver.find_element_by_id ("kw"). Send_keys (Keys.control,' V ')
    13. driver.find_element_by_id ("kw"). Send_keys (Keys.enter)

Selenium Basic Keyboard method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.