一.現象還原:
當新建.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文件中就不會再提示錯誤了。