在webdriver/remote/webelement.py中,定义了一般的DOM元素:
class WebElement(object): def __init__(self, parent, id_, w3c=False):这里面也包括:
找element: find_element...,screenshot操作,和前面的webdriver.py差不多。
元素的属性:
def tag_name(self): @property def text(self): def size(self): def id(self): def location(self):
还包括了一些元素的操作,比如:
def click(self): def submit(self): def clear(self): def send_keys(self, *value):还有一些元素的判断:
def is_selected(self) def is_enabled(self): def is_displayed(self):
这篇,貌似有点短,说点干货:
从下面看web element执行命令,
def _execute(self, command, params=None): """Executes a command against the underlying HTML element. Args: command: The name of the command to _execute as a string. params: A dictionary of named parameters to send with the command. Returns: The command's JSON response loaded into a dictionary object. """ if not params: params = {} params['id'] = self._id return self._parent.execute(command, params)从上面看出,执行命令是交给self._parent执行,而 self._parent则是webdriver,请参考上篇提到的实例化webelement.
