美文网首页
8-11(selenium-封装判断)

8-11(selenium-封装判断)

作者: 不知名的二狗 | 来源:发表于2019-08-28 21:33 被阅读0次

_call_函数

class hello():
    def __init__(self,b):
        print(b)
    # 将类模拟成函数
    def __call__(self, a):
        print(a)

if __name__ == "__main__":
    h = hello("hello")
    h("hhaha")

执行结果

hello
hhaha
title_is、title_contains

判断当前网页的标题

from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.baidu.com")
res1 = EC.title_is("百度一下,你就知道")(driver)
print(res1)
res2 = EC.title_contains("百度一下")(driver)
print(res2)
driver.close()
driver.quit()

相关文章

网友评论

      本文标题:8-11(selenium-封装判断)

      本文链接:https://www.haomeiwen.com/subject/iahdectx.html