Common WebDriver operations controlled by Python scripts & lt; 12 & gt; send_keys analog key input

Source: Internet
Author: User

The send_keys in WebDriver is used to simulate keyboard key input.

The send_keys method can simulate some key combinations:

  • Ctrl +
  • Ctrl + c
  • Ctrl + v
  • .

In addition, sometimes we need to use the tab key to move the focus to the next element during the test, and send_keys is also required. In some more complex cases, send_keys can also be used to simulate up/down keys to operate the drop-down list.

Test HTML code:

                                     send keys                                                                   send keys                                                                 A                    I think watir-webdriver is better than selenium-webdriver                                                                                           B                                                                                             

 

Test Python code:

 selenium  selenium.webdriver.common.keys  time    os.environ:  os.environ[==  + os.path.abspath(dr.find_element_by_id().send_keys((Keys.CONTROL,5).send_keys((Keys.CONTROL,5dr.find_element_by_id().send_keys((Keys.CONTROL,5dr.find_element_by_id().send_keys(, Keys.SPACE,,Keys.SPACE,5

 

Related Article

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.