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’
這是什么原因?
======================================
(我的環(huán)境是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. 在應用配置文件 app.php 中找不到’route_check_cache’配置項2. 跨類調用后,找不到方法3. sql語句 - 如何在mysql中批量添加用戶?4. 怎么php怎么通過數(shù)組顯示sql查詢結果呢,查詢結果有多條,如圖。5. mysql - 表名稱前綴到底有啥用?6. 編輯成功不顯示彈窗7. tp 6.0 數(shù)據(jù)查詢,求教!8. 為什么php修改數(shù)據(jù)無法同步到數(shù)據(jù)庫,只是當前頁面修改成功?9. 哭遼 求大佬解答 控制器的join方法怎么轉模型方法10. 在mybatis使用mysql的ON DUPLICATE KEY UPDATE語法實現(xiàn)存在即更新應該使用哪個標簽?
