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. angular.js - angular內(nèi)容過長展開收起效果2. docker網(wǎng)絡(luò)端口映射,沒有方便點(diǎn)的操作方法么?3. docker - 各位電腦上有多少個(gè)容器???容器一多,自己都搞混了,咋辦呢?4. docker綁定了nginx端口 外部訪問不到5. nignx - docker內(nèi)nginx 80端口被占用6. fragment - android webView 返回后怎么禁止重新渲染?7. docker不顯示端口映射呢?8. php - mysql 模糊搜索問題9. java - 為什么此私有靜態(tài)變量能被訪問呢?10. php - 第三方支付平臺(tái)在很短時(shí)間內(nèi)多次異步通知,訂單多次確認(rèn)收款
