0

你好,我有一些代码可以检查链接是否良好,但我无法运行它。

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

因为当我运行它时,我得到了错误:

while "profile" in l():
TypeError: 'WebElement' object is not callable
4

1 回答 1

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

于 2021-06-07T16:26:42.243 回答