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. docker 下面創建的IMAGE 他們的 ID 一樣?這個是怎么回事????2. 運行python程序時出現“應用程序發生異常”的內存錯誤?3. node.js - mongodb查找子對象的名稱為某個值的對象的方法4. html5 - datatables 加載不出來數據。5. javascript - QQ第三方登錄的問題6. 前端 - @media query 使用出現的問題?7. javascript - 在 model里定義的 引用表模型時,model為undefined。8. 利用IPMI遠程安裝centos報錯!9. 測試自動化html元素選擇器元素ID或DataAttribute [關閉]10. html5和Flash對抗是什么情況?

網公網安備