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