用Selenuim进行用户界面测试时,找不到链接错误


#1

按照书上的代码进行测试,但是报错,找不到项目链接,不知道是怎么回事,还请各位能帮忙看一下。
在命令行中的命令及报错是这样的:

 >>> from selenium import webdriver
>>> from selenium.webdriver.common.keys import Keys
>>> driver = webdriver.Firefox()
>>> driver.get('https://pypi.org')
>>> elem = driver.find_element_by_name('q')
>>> elem.click()
>>> elem.send_keys('Flask')
>>> elem.send_keys(Keys.RETURN)
>>> 'A simple framework for building complex web applications.' in driver.page_source
True
>>> elem = driver.find_element_by_link_text('Flask')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/xmboy/.local/share/virtualenvs/flask-todoism-KmgT8a7_/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 428, in find_element_by_link_text
    return self.find_element(by=By.LINK_TEXT, value=link_text)
  File "/home/xmboy/.local/share/virtualenvs/flask-todoism-KmgT8a7_/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 978, in find_element
    'value': value})['value']
  File "/home/xmboy/.local/share/virtualenvs/flask-todoism-KmgT8a7_/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/home/xmboy/.local/share/virtualenvs/flask-todoism-KmgT8a7_/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: Flask