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. 前端 - 應該先從angularJS , vue.js , react 這些框架中的哪個開始入手?2. 用工具實現在微信里面生成帶二維碼的海報?3. angular.js - angurlarJS的安卓的微信端中用加載ngCookies會出錯的問題4. PHPstudy創建網站成功,用瀏覽器打開文件,瀏覽器地址顯示“loaclhost:63342/,錯5. javascript - windows下如何使用babel,遇到了困惑6. css3 - IE678兼容last-child的方法 請教7. html5 - 前端面試碰到了一個緩存數據的問題,來論壇上請教一下8. node.js - 利用vue-cli 構建執行到npm run dev 報錯,求解~9. javascript - jq 上傳圖片成功后添加一個新的上傳框時出現問題10. javascript - 如何使用nodejs 將.html 文件轉化成canvas
