学习思路:
查看github项目的源码,每个方法都有介绍及方法
https://github.com/mherrmann/selenium-python-helium/blob/master/helium/__init__.py
__all__ = [ | |
# Actions: 方法 | |
‘attach_file‘, ‘click‘, ‘doubleclick‘, ‘drag‘, ‘drag_file‘, ‘find_all‘, | |
‘get_driver‘, ‘go_to‘, ‘highlight‘, ‘hover‘, ‘kill_browser‘, ‘press‘, | |
‘refresh‘, ‘rightclick‘, ‘scroll_down‘, ‘scroll_left‘, ‘scroll_right‘, | |
‘scroll_up‘, ‘select‘, ‘set_driver‘, ‘start_chrome‘, ‘start_firefox‘, | |
‘switch_to‘, ‘wait_until‘, ‘write‘, | |
# Predicates: | |
‘Alert‘, ‘Button‘, ‘CheckBox‘, ‘ComboBox‘, ‘Config‘, ‘Image‘, ‘Link‘, | |
‘ListItem‘, ‘Point‘, ‘S‘, ‘RadioButton‘, ‘Text‘, ‘TextField‘, ‘Window‘, | |
# Keys: | |
‘ADD‘, ‘ALT‘, ‘ARROW_DOWN‘, ‘ARROW_LEFT‘, ‘ARROW_RIGHT‘, ‘ARROW_UP‘, | |
‘BACK_SPACE‘, ‘CANCEL‘, ‘CLEAR‘, ‘COMMAND‘, ‘CONTROL‘, ‘DECIMAL‘, ‘DELETE‘, | |
‘DIVIDE‘, ‘DOWN‘, ‘END‘, ‘ENTER‘, ‘EQUALS‘, ‘ESCAPE‘, ‘F1‘, ‘F2‘, ‘F3‘, | |
‘F4‘, ‘F5‘, ‘F6‘, ‘F7‘, ‘F8‘, ‘F9‘, ‘F10‘, ‘F11‘, ‘F12‘, ‘HELP‘, ‘HOME‘, | |
‘INSERT‘, ‘LEFT‘, ‘LEFT_ALT‘, ‘LEFT_CONTROL‘, ‘LEFT_SHIFT‘, ‘META‘, | |
‘MULTIPLY‘, ‘NULL‘, ‘NUMPAD0‘, ‘NUMPAD1‘, ‘NUMPAD2‘, ‘NUMPAD3‘, ‘NUMPAD4‘, | |
‘NUMPAD5‘, ‘NUMPAD6‘, ‘NUMPAD7‘, ‘NUMPAD8‘, ‘NUMPAD9‘, ‘PAGE_DOWN‘, | |
‘PAGE_UP‘, ‘PAUSE‘, ‘RETURN‘, ‘RIGHT‘, ‘SEMICOLON‘, ‘SEPARATOR‘, ‘SHIFT‘, | |
‘SPACE‘, ‘SUBTRACT‘, ‘TAB‘, ‘UP‘ | |
] |
举例:
click
def click(element):
"""
:param element: The element or point to click.
:type element: str, unicode, :py:class:`HTMLElement`, \
:py:class:`selenium.webdriver.remote.webelement.WebElement` or :py:class:`Point`
Clicks on the given element or point. Common examples are::
click("Sign in")
click(Button("OK"))
click(Point(200, 300))
click(ComboBox("File type").top_left + (50, 0))
"""
Text
class Text(HTMLElement):
"""
Lets you identify any text or label on a web page. This is most useful for
checking whether a particular text exists::
if Text("Do you want to proceed?").exists():
click("Yes")
``Text`` also makes it possible to read plain text data from a web page. For
example, suppose you have a table of people‘s email addresses. Then you
can read John‘s email addresses as follows::
Text(below="Email", to_right_of="John").value
Similarly to ``below`` and ``to_right_of``, the keyword parameters ``above``
and ``to_left_of`` can be used to search for texts above and to the left of
other web elements.
"""
原文:https://www.cnblogs.com/weitung/p/13532947.html