selenium_webdriver 驅(qū)動(dòng)不了瀏覽器問(wèn)題
創(chuàng)新互聯(lián)公司主要從事成都網(wǎng)站建設(shè)、成都網(wǎng)站制作、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)上城,十余年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來(lái)電咨詢建站服務(wù):028-86922220
最近很多同學(xué),自己在學(xué)習(xí)selenium工具時(shí),碰到一個(gè)最多的問(wèn)題就是為什么我創(chuàng)建了一個(gè)瀏覽器實(shí)例,driver.get(url)時(shí),卻打不開瀏覽器,或者就算打開了無(wú)法輸入相應(yīng)的URL,這是為什么呢?
筆者最近在自學(xué)selenium工具時(shí),也碰到了這些問(wèn)題,最后發(fā)現(xiàn)是驅(qū)動(dòng)版本的問(wèn)題,因?yàn)閣ebdriver 在啟用我們指定的瀏覽器 Chrome/Firefox/I e時(shí),需要調(diào)用相應(yīng)的驅(qū)動(dòng),不同的瀏覽器版本對(duì)應(yīng)的驅(qū)動(dòng)不一樣,有些驅(qū)動(dòng)只支持哪幾個(gè)瀏覽器相關(guān)版本,例如以Chrome為例:
----------ChromeDriver v2.7 (2013-11-22)---------- Supports Chrome v30-33 Resolved issue 615: ChromeDriver doesn't work well with auto detect proxy settings [OS-Windows, Pri-0] Resolved issue 614: Implement new redirectionless /session command [Pri-0] Resolved issue 625: logging broken on windows [Pri-0] Resolved issue 573: chromedriver crashes on windows occasionally [OS-Windows, Pri-1] ----------ChromeDriver v2.6 (2013-11-04)---------- Supports Chrome v29-32 Resolved issue 599: Chromedriver failes after MacOS X Mavericks upgrade [OS-Mac, Pri-0, Type-Defect] Resolved issue 585: Return user data dir via capabilities [] ----------ChromeDriver v2.5 (2013-11-01)---------- Supports Chrome v29-32 Resolved issue 600: Support minidump for chrome crashes on Linux with a new capability minidump_path. [Pri-0] Resolved issue 569: A change in blink breaks scrolling an element into view [Pri-0] Resolved issue 554: Release notes broken [Pri-0] Resolved issue 545: hang when debugger is invoked via JS [Pri-0] ----------ChromeDriver v2.4 (2013-09-30)---------- Supports Chrome v29-32 Resolved issue 444: chromedriver sometimes hangs when launching chrome (chrome fails to bind to debug port) [Pri-0] Resolved issue 529: WebDriver clients fail when attempting to use empty chromeOption binary string [Pri-0] Resolved issue 536: remote debugging port taken during startup [Pri-0] Resolved issue 520: Some commands hangs if the target window already crashes. [] Resolved issue 519: Support JS heap snapshot [] ----------ChromeDriver v2.3 (2013-09-02)---------- Resolved issue 309: Screenshot is blank from an VM instance without an open RDC connection [Pri-1] Resolved issue 445: chromedriver crashes when port is in use [Pri-1] Resolved issue 461: TouchUp, TouchDown, and TouchMove commands [OS-All, Pri-1] Resolved issue 489: No longer using packed extension id when loading custom extensions [Pri-3] Resolved issue 491: Extension does not have its _id_ [Pri-3] Resolved issue 497: unrecognized chrome option: useExistingBrowser [Pri-3] ----------ChromeDriver v2.2 (2013-08-06)----------
以上我們可以看到,不同的ChromeDriver 支持的瀏覽器版本是不一樣的,如果我們拿ChromeDriver v2.4 的驅(qū)動(dòng),去驅(qū)動(dòng)Chrome 35或者以上的版本,可能會(huì)出現(xiàn)前面提到的各種問(wèn)題,其他類型瀏覽器類似,碰到這類問(wèn)題一般都是驅(qū)動(dòng)引起的。
ChromeDriver 驅(qū)動(dòng)下載及支持的瀏覽器版本號(hào),以下鏈接可以找到:
http://chromedriver.storage.googleapis.com/index.html?path=2.7/
好了,時(shí)間不早了,就寫到這里吧,有問(wèn)題再更新。。