Selenium python (quad) keyboard events

Source: Internet
Author: User
Tags selenium python

#!/usr/bin/python
#-*-Coding:utf-8-*-
__author__ = ' Zuoanvip '

#在实际测试过程中, sometimes we need to use the TAB key to move the focus to the next element that needs to be manipulated to verify that the elements are sorted correctly. The keys () class of Webdriver provides all keystrokes on the keyboard and can simulate assemblies such as CTRL + A

#引入Keys包
From Selenium.webdriver.common.keys import keys
From selenium import Webdriver
Import time

Driver = Webdriver. Firefox ()
Driver.get (' http://www.xxxx.com ')
#定位目标元素
Target_element = driver.find_element_by_id (' xx ')
Time.sleep (5)

#输入框输入内容
Target_element.send_keys (' Selenium ')

#删除
Target_element.send_keys (Keys.back_space)

#输入空格 + Tutorials
Target_element.send_keys (Keys.backspace)
Target_element.send_keys (' tutorial ')

#全选输入框内容
Target_element.send_keys (Keys.control, ' a ')

#剪切输入框内容
Target_element.send_keys (Keys.control, ' x ')

#输入框重新输入内容
Target_element.send_keys (Keys.control, ' V ')

#回车键
Target_element.send_keys (Keys.enter)

#制表键 (Tab)
Target_element.send_keys ((Keys.tab))


Selenium python (quad) keyboard events

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.