简体   繁体   中英

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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