python - 出錯:Unresolved reference ’selenium’是什么原因
問題描述
# -*- coding: utf-8 -*-from selenium import seleniumimport unittest, time, reclass rc(unittest.TestCase): def setUp(self):self.verificationErrors = []self.selenium = selenium('localhost', 4444, '*chrome', 'https://www.baidu.com/')self.selenium.start()def test_rc(self):sel = self.seleniumsel.open('/')sel.type('id=kw', 'selenium')sel.click('id=container')sel.click('id=su')def tearDown(self):self.selenium.stop()self.assertEqual([], self.verificationErrors)if __name__ == '__main__': unittest.main()
這是用selenium ide 錄的,轉成 selenium remote control代碼
在ide測試是通過的。
但在pycharm里打開,第一行from selenium import selenium
就會出錯:Unresolved reference ’selenium’
這是什么原因?
======================================
(我的環境是python3.5
selenium3.3.1
selenium-server-standalone-3.3.1.jar)
問題解答
回答1:打開Pycharm設置搜索Project Interpreter查看是否有對應的包,以及Python版本是否和你的Python版本一致
確認你的selenium在PYTHONPATH中
添加selenium到你的PYTHONPATH中 or Pycharm依賴中
回答2:這個問題是由于你的電腦安裝了多個Python ,解決方法請參考。
https://zhuanlan.zhihu.com/p/...
相關文章:
1. python - 有什么好的可以收集貨幣基金的資源?2. docker容器呢SSH為什么連不通呢?3. docker鏡像push報錯4. docker安裝后出現Cannot connect to the Docker daemon.5. docker start -a dockername 老是卡住,什么情況?6. docker網絡端口映射,沒有方便點的操作方法么?7. node.js - nodejs debug問題8. MySQL數據庫中文亂碼的原因9. Docker for Mac 創建的dnsmasq容器連不上/不工作的問題10. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””
