This anthology link: https://www.jianshu.com/nb/25338984
method
-
clear()
ClearIf there are elements in the current text, the text will be emptied
-
click()
ClickClick on the current element
-
get_attribute(name)
Acquiring propertyGetting element attribute / property
Exact match priority return value of the property name, and if not, the value of the attribute name included in the name is returned.
-
screenshot(filename)
Get shotScreenshot obtain the current element, saved as png, preferably with an absolute path
-
send_keys(value)
Analog type elementsThe analog input to the current element
webelement This method should be there in Chrome bug, it can not be used.
-
submit()
submit Formsubmit Form
In the page elements, the same offer find_elements_by_*
and other search method, you can find a range limited to the current element.
Attributes
-
text
Gets the current text element
-
tag_name
Gets the tag name of the current element
-
size
Gets the size of the current element
-
screenshot_as_png
Elements of the current screenshot and save it as png format binary data
-
screenshot_as_base64
Elements of the current screenshot and save it as base64 encoded string
-
rect
Gets a dictionary that contains the size and position of the current element
-
parent
Get the parent node of the current element
-
location
The position of the current element
-
id
The current value of the element id, Selenium mainly used internally, can be used to determine whether the two elements are the same element
Keys
We often need to simulate keyboard input when the input common values in send_keys()
the incoming string to be entered like method.
However, we sometimes use some special key, this time we need to use our Keys class.
Jane cases
from selenium.webdriver.common.keys import Keys
elem.send_keys(Keys.CONTROL, 'c')
属性
这个Keys
类有很多属性,每个属性对应一个按键。所有的属性如下所示:
ADD = u'\ue025'
ALT = u'\ue00a'
ARROW_DOWN = u'\ue015'
ARROW_LEFT = u'\ue012'
ARROW_RIGHT = u'\ue014'
ARROW_UP = u'\ue013'
BACKSPACE = u'\ue003'
BACK_SPACE = u'\ue003'
CANCEL = u'\ue001'
CLEAR = u'\ue005'
COMMAND = u'\ue03d'
CONTROL = u'\ue009'
DECIMAL = u'\ue028'
DELETE = u'\ue017'
DIVIDE = u'\ue029'
DOWN = u'\ue015'
END = u'\ue010'
ENTER = u'\ue007'
EQUALS = u'\ue019'
ESCAPE = u'\ue00c'
F1 = u'\ue031'
F10 = u'\ue03a'
F11 = u'\ue03b'
F12 = u'\ue03c'
F2 = u'\ue032'
F3 = u'\ue033'
F4 = u'\ue034'
F5 = u'\ue035'
F6 = u'\ue036'
F7 = u'\ue037'
F8 = u'\ue038'
F9 = u'\ue039'
HELP = u'\ue002'
HOME = u'\ue011'
INSERT = u'\ue016'
LEFT = u'\ue012'
LEFT_ALT = u'\ue00a'
LEFT_CONTROL = u'\ue009'
LEFT_SHIFT = u'\ue008'
META = u'\ue03d'
MULTIPLY = u'\ue024'
NULL = u'\ue000'
NUMPAD0 = u'\ue01a'
NUMPAD1 = u'\ue01b'
NUMPAD2 = u'\ue01c'
NUMPAD3 = u'\ue01d'
NUMPAD4 = u'\ue01e'
NUMPAD5 = u'\ue01f'
NUMPAD6 = u'\ue020'
NUMPAD7 = u'\ue021'
NUMPAD8 = u'\ue022'
NUMPAD9 = u'\ue023'
PAGE_DOWN = u'\ue00f'
PAGE_UP = u'\ue00e'
PAUSE = u'\ue00b'
RETURN = u'\ue006'
RIGHT = u'\ue014'
SEMICOLON = u'\ue018'
SEPARATOR = u'\ue026'
SHIFT = u'\ue008'
SPACE = u'\ue00d'
SUBTRACT = u'\ue027'
TAB = u'\ue004'
UP = u'\ue013'