一.现象还原:
当新建.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.1Libsite-packages),最后点击【OK】
4.选择selenium包的路径,再点击“Sources”
5.最后再“Apply”应用,再返回.py文件中就不会再提示错误了。