python - 出錯(cuò):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 錄的,轉(zhuǎn)成 selenium remote control代碼
在ide測試是通過的。
但在pycharm里打開,第一行from selenium import selenium
就會(huì)出錯(cuò):Unresolved reference ’selenium’
這是什么原因?
======================================
(我的環(huán)境是python3.5
selenium3.3.1
selenium-server-standalone-3.3.1.jar)
問題解答
回答1:打開Pycharm設(shè)置搜索Project Interpreter查看是否有對應(yīng)的包,以及Python版本是否和你的Python版本一致
確認(rèn)你的selenium在PYTHONPATH中
添加selenium到你的PYTHONPATH中 or Pycharm依賴中
回答2:這個(gè)問題是由于你的電腦安裝了多個(gè)Python ,解決方法請參考。
https://zhuanlan.zhihu.com/p/...
相關(guān)文章:
1. 如何用筆記本上的apache做微信開發(fā)的服務(wù)器2. 冒昧問一下,我這php代碼哪里出錯(cuò)了???3. php - 淘寶訂單拆單表設(shè)計(jì)4. mysql優(yōu)化 - MySQL如何為配置表建立索引?5. MySQL主鍵沖突時(shí)的更新操作和替換操作在功能上有什么差別(如圖)6. windows誤人子弟啊7. 實(shí)現(xiàn)bing搜索工具urlAPI提交8. 數(shù)據(jù)庫 - Mysql的存儲過程真的是個(gè)坑!求助下面的存儲過程哪里錯(cuò)啦,實(shí)在是找不到哪里的問題了。9. 我在網(wǎng)址中輸入localhost/abc.php顯示的是not found是為什么呢?10. 關(guān)于mysql聯(lián)合查詢一對多的顯示結(jié)果問題
