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 bottle跑起來以后,定時執行的任務為什么每次都重復(多)執行一次?2. python - 爬蟲模擬登錄后,爬取csdn后臺文章列表遇到的問題3. html5 - HTML代碼中的文字亂碼是怎么回事?4. 視頻文件不能播放,怎么辦?5. javascript - vue2如何獲取v-model變量名6. javascript - 求幫助 , ATOM不顯示界面!!!!7. mysql - 分庫分表、分區、讀寫分離 這些都是用在什么場景下 ,會帶來哪些效率或者其他方面的好處8. javascript - 為什么在谷歌控制臺 輸出1的時候,輸出的1立馬就不見了9. javascript - angular使從elastichearch中取出的文本高亮顯示,如圖所示10. javascript - ios返回不執行js怎么解決?
