1. 程式人生 > >【PyCharm編輯器】之引用selenium包提示錯誤:Unresolved reference 'selenium' less... (Ctrl+F1)

【PyCharm編輯器】之引用selenium包提示錯誤:Unresolved reference 'selenium' less... (Ctrl+F1)

一.現象還原:

當新建.py檔案時,需要引用selenium中的方法時,報錯,提示紅波浪線:

Unresolved reference 'selenium' less... (Ctrl+F1) 
This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.

二.解決辦法:

1.點選編輯器“File”->點選“settings”

2.在“settings”中,選擇“Project:Pytest”->“Project Structre”->點選“Add Content Root”

3.找到安裝selenium的路徑,紅色字型(例:F:\軟體\python3.6.1\Lib\site-packages),最後點選【OK】

4.選擇selenium包的路徑,再點選“Sources”

 5.最後再“Apply”應用,再返回.py檔案中就不會再提示錯誤了。