seldom
seldom copied to clipboard
get_elements方法在找不到元素的时候,希望可以返回空列表以便做判断,目前直接抛异常了,用len()也不能处理
感谢建议,修改了代码,支持返回 空 list()
import seldom
class BaiduTest(seldom.TestCase):
def test_case(self):
"""a simple test case """
self.open("https://www.baidu.com")
ret = self.get_elements(id_="error")
print("-->", ret)
log
test_case (selenium_sample.BaiduTest)
a simple test case ... 2021-08-17 01:11:55 [INFO] 📖 https://www.baidu.com
DevTools listening on ws://127.0.0.1:64664/devtools/browser/646e9158-2c47-4b51-bb57-5c30a3234dc4
2021-08-17 01:11:57 [WARNING] ❌ Find 0 element through: id=error.
--> []
ok
----------------------------------------------------------------------
Ran 1 test in 2.527s