selenium的webdriver获取一个元素之后,将会建立一个webelement对象,这个对象根据使用浏览器的不同,会变为firefox的FirefoxWebElement或者chrome的
ChromeWebElement
于是有必要对WebElement进行研究,检查其所有属性如下:
>>> dir(webdriver.firefox.webelement.FirefoxWebElement) ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__form at__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_s ubclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclas shook__', '__weakref__', '_execute', '_upload', 'anonymous_children', 'clear', ' click', 'find_anonymous_element_by_attribute', 'find_element', 'find_element_by_ class_name', 'find_element_by_css_selector', 'find_element_by_id', 'find_element _by_link_text', 'find_element_by_name', 'find_element_by_partial_link_text', 'fi nd_element_by_tag_name', 'find_element_by_xpath', 'find_elements', 'find_element s_by_class_name', 'find_elements_by_css_selector', 'find_elements_by_id', 'find_ elements_by_link_text', 'find_elements_by_name', 'find_elements_by_partial_link_ text', 'find_elements_by_tag_name', 'find_elements_by_xpath', 'get_attribute', ' get_property', 'id', 'is_displayed', 'is_enabled', 'is_selected', 'location', 'l ocation_once_scrolled_into_view', 'parent', 'rect', 'screenshot', 'screenshot_as _base64', 'screenshot_as_png', 'send_keys', 'size', 'submit', 'tag_name', 'text' , 'value_of_css_property']