Python+selenium+eclipse performing web Automation (iv) Control processing

Source: Internet
Author: User

element is positioned to perform related actions based on the type of page element, using element to refer to a positioned page element

1. Input box

Includes a text input box and a password input box, the available actions are clear () and Send_keys (), with the following specific usage

Element.clear () #清空输入框当前内容
Element.send_keys ("string") #项输入框发送字符串

2. Radio Box and check box

The available actions are Is_select () and click (), as follows
Element.is_selected () #判断当前选择控件是否被选中

Element.click () #单击选择当前控件

3. button

The available actions are Get_attribute () and click (), as follows

Element.get_attribute ("string") #根据输入的字符串查找相关属性

Element.click () #单击插件

4. List

The list control needs to import the Select module with the following code

From Selenium.webdriver.support.select Import Select
The operation is as follows

Select (Element). Select_by_value ("value") #根据value值选择选项, the value is "value", as required by the self-input

Select (Element). Select_by_index ("index") #根据index值选择选项, the specific index value is "index", as required by the self-input

Select (Element). Select_by_visible_text ("text") #根据visible_text选择选项, the value of the specific visible_text is "text", as required by the self-input

5. Pop-up window

1), if the pop-up window is a single-selection window, you can send keyboard events through the Actionchains control to complete the operation. The operation is as follows

From selenium.webdriver.common.action_chains import Actionchains #导入ActionChains模块

Browser1=webdriver. Firefox ()
Browser1.get ("www.xxxx.com")

Actionchains (Browser1). Send_keys (Keys.enter). Perform () #在browser界面发送ENTER按键

2), if the pop-up window is a multi-box, you need to switch to the popup body through the Switch_to_frame ("FrameName") operation, and then do some related actions on the required controls

Python+selenium+eclipse performing web Automation (iv) Control processing

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.