WebDriverException:消息:“無(wú)法連接到ChromeDriver”utils.is_connectable(self.port)中的錯(cuò)誤:
1.檢查您是否安裝了最新版本的chrome brwoser-> 2.如果沒(méi)有,請(qǐng)安裝最新版本的chrome installchrome 3.獲取適當(dāng)版本的chrome驅(qū)動(dòng)程序通過(guò)以下鏈接http://chromedriver.storage.googleapis.com/index.html4.解壓縮chromedriver.zip5.將文件移至/ usr / bin /目錄 6.轉(zhuǎn)到/ usr / bin /目錄,則需要運(yùn)行“ ”之類的文件以將其標(biāo)記為可執(zhí)行。7.最后,您可以執(zhí)行代碼。
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計(jì)算機(jī)上的Chrome瀏覽器35.0.1916.114版上運(yùn)行測(cè)試
/home/varunm/EC_WTF_0.4.10/EC_WTF0.4.10_Project/wtframework/wtf/drivers/chromedriver
實(shí)際上,我修復(fù)了路徑問(wèn)題,因?yàn)槿绻麊?wèn)題出在路徑上,則錯(cuò)誤消息有所不同
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')
如果路徑錯(cuò)誤,我將收到其他錯(cuò)誤,但是現(xiàn)在錯(cuò)誤是在建立連接時(shí)
相關(guān)文章:
1. javascript - h5 video層級(jí)太高導(dǎo)致浮在div上面,如何解決?2. mysql ER_BAD_DB_ERROR: Unknown database ’test’3. linux - Ubuntu下編譯Vim8(+python)無(wú)數(shù)次編譯失敗4. python - pyspider爬pdf爬了一小段時(shí)間后就不動(dòng)了5. mysql - 記得以前在哪里看過(guò)一個(gè)估算時(shí)間的網(wǎng)站6. 如何合并兩張具有相同結(jié)構(gòu)的mysql表7. javascript - Ajax加載Json時(shí),移動(dòng)端頁(yè)面向左上角縮小一截兒,加載完成后才正常顯示,這該如何解決?8. python中怎么對(duì)列表以區(qū)間進(jìn)行統(tǒng)計(jì)?9. css - 請(qǐng)問(wèn)B站頂部的模糊半透明導(dǎo)航條是怎么實(shí)現(xiàn)的呢?10. python運(yùn)行后沒(méi)有任何反饋要怎么排查
