# 4. Finds




```webium.find.Finds``` 方法的用法跟```Find```方法基本是一致的，不过返回的是```WebElement```列表。

```python
from selenium.webdriver.common.by import By
from webium import BasePage, Finds

class LinksPage(BasePage):
    links = Finds(by=By.TAG_NAME, value='a')

    def __init__(self):
        super(LinksPage, self).__init__(url='http://itest.info')


if __name__ == '__main__':
    page = LinksPage()
    page.open()
    print('Number of links: ' + str(len(page.links)))
```

我们甚至可以动态返回满足条件的一组元素。

```python
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webelement import WebElement
from webium import BasePage, Finds


class Link(WebElement):
    def is_secure(self):
        return self.get_attribute('href').startswith('https://')


class TypedPage(BasePage):
    links = Finds(Link, By.TAG_NAME, 'a')

    def __init__(self):
        super(TypedPage, self).__init__(url='http://itest.info')

    def get_unsecured_links(self):
        return filter(lambda link: not link.is_secure(), self.links)


if __name__ == '__main__':
    page = TypedPage()
    page.open()
    print('Number of unsecured links: ' + str(len(page.get_unsecured_links())))

```



原始封面

![课程图片](https://images.unsplash.com/photo-1507208773393-40d9fc670acf?w=300)


