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. mysql數據庫每次查詢是一條線程嗎?2. css - 關于ul的布局3. docker不顯示端口映射呢?4. 使用uuid,并不能利用mysql的索引,有什么解決辦法?5. javascript - 數組原聲方法中的一段代碼6. javascript - 前端開發 本地靜態文件頻繁修改,預覽時的緩存怎么解決?7. android - 優酷的安卓及蘋果app還在使用flash技術嗎?8. JavaScript如何循序漸進,有效的學習?看不下去怎么辦?9. python - linux怎么在每天的凌晨2點執行一次這個log.py文件10. java - public <T> T findOne(T record) 這是什么意思
