WebDriverException:消息:“無法連接到ChromeDriver”utils.is_connectable(self.port)中的錯誤:
1.檢查您是否安裝了最新版本的chrome brwoser-> 2.如果沒有,請安裝最新版本的chrome installchrome 3.獲取適當版本的chrome驅動程序通過以下鏈接http://chromedriver.storage.googleapis.com/index.html4.解壓縮chromedriver.zip5.將文件移至/ usr / bin /目錄 6.轉到/ usr / bin /目錄,則需要運行“ ”之類的文件以將其標記為可執行。7.最后,您可以執行代碼。
import osfrom selenium import webdriverfrom pyvirtualdisplay import displaydisplay = display(visible=0, size=(800, 600))display.start()driver = webdriver.Chrome()driver.get('http://www.google.com')print driver.page_source.encode(’utf-8’)driver.quit()display.stop()解決方法
我正在嘗試使用chromedriver 2.10在CentOS計算機上的Chrome瀏覽器35.0.1916.114版上運行測試
/home/varunm/EC_WTF_0.4.10/EC_WTF0.4.10_Project/wtframework/wtf/drivers/chromedriver
實際上,我修復了路徑問題,因為如果問題出在路徑上,則錯誤消息有所不同
def start(self): ''' Starts the ChromeDriver Service. :Exceptions: - WebDriverException : Raised either when it can’t start the service or when it can’t connect to the service ''' env = self.env or os.environ try:self.process = subprocess.Popen([ self.path,'--port=%d' % self.port] + self.service_args,env=env,stdout=PIPE,stderr=PIPE) except:raise WebDriverException( 'ChromeDriver executable needs to be available in the path. Please download from http://chromedriver.storage.googleapis.com/index.html and read up at http://code.google.com/p/selenium/wiki/ChromeDriver') count = 0 while not utils.is_connectable(self.port):count += 1time.sleep(1)if count == 30: raise WebDriverException('Can not connect to the ChromeDriver')
如果路徑錯誤,我將收到其他錯誤,但是現在錯誤是在建立連接時
相關文章:
1. 關于docker下的nginx壓力測試2. docker images顯示的鏡像過多,狗眼被亮瞎了,怎么辦?3. java - 阿里的開發手冊中為什么禁用map來作為查詢的接受類?4. dockerfile - [docker build image失敗- npm install]5. nignx - docker內nginx 80端口被占用6. html5 - 使用echarts中的圖表 一個頁面導入了好幾個js圖表 實現echarts圖表隨著瀏覽器窗口變化而變化時出現了問題7. 在windows下安裝docker Toolbox 啟動Docker Quickstart Terminal 失敗!8. dockerfile - 我用docker build的時候出現下邊問題 麻煩幫我看一下9. docker api 開發的端口怎么獲取?10. python3.x - git bash如何運行.bat文件?
