简体   繁体   English

类型错误:'WebElement' object 不可调用

[英]TypeError: 'WebElement' object is not callable

hello i have this little peace of code that will check if a link is good but i can't run it.你好,我有一些代码可以检查链接是否良好,但我无法运行它。

links = driver.find_elements_by_partial_link_text('')
l = links[random.randint(0, len(links)-1)]
while "profile" in l():
    print("finding new link")
    links = driver.find_elements_by_partial_link_text('')
    l = links[random.randint(0, len(links) - 1)]
l.click()

cause when i run it i get the error:因为当我运行它时,我得到了错误:

while "profile" in l():
TypeError: 'WebElement' object is not callable
import random
links = driver.find_elements_by_partial_link_text('')
l = links[random.randint(0, len(links)-1)]
while True:
    if l.text.find("profile") >= 0:
        print("finding new link")
        links = driver.find_elements_by_partial_link_text('')
        l = links[random.randint(0, len(links) - 1)]
    else:
        break;
l.click()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM