def find_elements_by_class_name(self, name):
"""
Finds elements by class name.
:Args:
- name: The class name of the elements to find.
:Returns:
- list of WebElement - a list with elements if any was found. An
empty list if not
:Usage:
::
elements = driver.find_elements_by_class_name('foo')
"""
warnings.warn("find_elements_by_* commands are deprecated. Please use find_elements() instead")
return self.find_elements(by=By.CLASS_NAME, value=name)
def find_elements_by_xpath(self, xpath):
"""
Finds multiple elements by xpath.
:Args:
- xpath - The xpath locator of the elements to be found.
:Returns:
- list of WebElement - a list with elements if any was found. An
empty list if not
:Usage:
::
elements = driver.find_elements_by_xpath("//div[contains(@class, 'foo')]")
"""
warnings.warn("find_elements_by_* commands are deprecated. Please use find_elements() instead")
return self.find_elements(by=By.XPATH, value=xpath)
按类名(类名)查找元素
find_elements_by_class_name(class_name)按类名查找元素,如果找到元素,则返回包含元素的列表。如果没有,则为空列表。其定义如下:
值得注意的是
find_elements_by_class_name()
接受单个类作为参数。通过多个类,您将面临以下错误:例如:
通过xpath(xpath)
find_elements_by_xpath(xpath)通过xpath查找多个元素,如果找到任何元素,则返回包含元素的列表。如果没有,则为空列表。其定义如下:
例如:
相关问题 更多 >
编程相关推荐