在pycharm中使用find_element_by_id()進行元素報錯:DeprecationWarning: find_element_by_* commands are deprecated.
原因:selenium使用的是4.0版本。
解決方法:不使用4.0版本改為使用3.3.1版本。
具體操作:
1.卸載selenium4.0。管理員身份運行cmd,輸入pip uninstall selenium,然后輸入Y確定刪除selenium4.0,刪除成功后輸入pip install selenium==3.3.1指定安裝3.3.1版本,確定看到安裝成功。
2.在pycharm中刪除selenium。打開pycharm,選擇File,然后點擊settings。
3.找到selenium4.0並刪除。在Settings中選擇Python Interpreter,然后選中selenium,點擊“-”號,將selenium移除。
4.安裝selenium3.3.1。點擊“+”號,然后輸入selenium搜索到selenium后,勾選Specify version,再選擇3.3.1,然后點擊Install Package,等待安裝成功即可。