大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
selenium_webdriver 驱动不了浏览器问题
成都创新互联专注于企业营销型网站建设、网站重做改版、慈溪网站定制设计、自适应品牌网站建设、H5建站、商城系统网站开发、集团公司官网建设、外贸网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为慈溪等各大城市提供网站开发制作服务。最近很多同学,自己在学习selenium工具时,碰到一个最多的问题就是为什么我创建了一个浏览器实例,driver.get(url)时,却打不开浏览器,或者就算打开了无法输入相应的URL,这是为什么呢?
笔者最近在自学selenium工具时,也碰到了这些问题,最后发现是驱动版本的问题,因为webdriver 在启用我们指定的浏览器 Chrome/Firefox/I e时,需要调用相应的驱动,不同的浏览器版本对应的驱动不一样,有些驱动只支持哪几个浏览器相关版本,例如以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 的驱动,去驱动Chrome 35或者以上的版本,可能会出现前面提到的各种问题,其他类型浏览器类似,碰到这类问题一般都是驱动引起的。
ChromeDriver 驱动下载及支持的浏览器版本号,以下链接可以找到:
http://chromedriver.storage.googleapis.com/index.html?path=2.7/
好了,时间不早了,就写到这里吧,有问题再更新。。
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。