我正在使用selenium-webdriver
来自动执行与网络浏览器相关的任务。但是,当我执行以下操作时,会获得一大块messgaes
,如下所示。为什么这样,你能告诉我吗?以及如何压制它?
irb(main):001:0> require "selenium-webdriver"
=> true
irb(main):002:0> driver=Selenium::WebDriver.for :firefox
*** LOG addons.manager: Application has been upgraded
*** LOG addons.xpi: startup
*** WARN addons.xpi: Ignoring missing add-on in C:\Program Files\SearchPredict\P
RFireFox
*** WARN addons.xpi: Ignoring missing add-on in C:\Program Files\SpeedBit Video
Downloader\SPFireFox
*** WARN addons.xpi: Ignoring missing add-on in C:\Program Files\Web Assistant\F
irefox
*** WARN addons.xpi: Ignoring missing add-on in C:\Program Files\Iminent\webboos
ter@iminent.com
*** LOG addons.xpi: Skipping unavailable install location app-system-local
*** LOG addons.xpi: Skipping unavailable install location app-system-share
*** LOG addons.xpi: checkForChanges
*** LOG addons.xpi-utils: Opening database
*** LOG addons.xpi-utils: Creating database schema
*** LOG addons.xpi: New add-on fxdriver@googlecode.com installed in app-profile
*** Blocklist::_loadBlocklistFromFile: blocklist is disabled
*** LOG addons.xpi: New add-on {F17C1572-C9EC-4e5c-A542-D05CBB5C5A08} installed
in winreg-app-user
*** LOG addons.xpi: New add-on ffxtlbr@babylon.com installed in app-global
*** WARN addons.xpi: Add-on is invalid: Error: Directory C:\Program Files\Mozill
a Firefox\extensions\ffxtlbr@babylon.com does not contain a valid install manife
st
*** WARN addons.xpi: Could not uninstall invalid item from locked install locati
on
*** LOG addons.xpi: New add-on {1FD91A9C-410C-4090-BBCC-55D3450EF433} installed
in app-global
*** LOG addons.xpi: New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed
in app-global
*** LOG addons.xpi: New add-on m3ffxtbr@mywebsearch.com installed in winreg-app-
global
*** LOG addons.xpi: New add-on avg@toolbar installed in winreg-app-global
*** LOG addons.xpi: New add-on daplinkchecker@speedbit.com installed in winreg-a
pp-global
*** LOG addons.xpi: New add-on wrc@avast.com installed in winreg-app-global
*** LOG addons.xpi: Updating database with changes to installed add-ons
*** LOG addons.xpi-utils: Updating add-on states
*** LOG addons.xpi-utils: Writing add-ons list
*** LOG addons.manager: shutdown
*** LOG addons.xpi: shutdown
*** LOG addons.xpi-utils: shutdown
*** LOG addons.xpi-utils: Database closed
*** LOG addons.xpi: startup
*** WARN addons.xpi: Ignoring missing add-on in C:\Program Files\SearchPredict\P
RFireFox
*** WARN addons.xpi: Ignoring missing add-on in C:\Program Files\SpeedBit Video
Downloader\SPFireFox
*** WARN addons.xpi: Ignoring missing add-on in C:\Program Files\Web Assistant\F
irefox
*** WARN addons.xpi: Ignoring missing add-on in C:\Program Files\Iminent\webboos
ter@iminent.com
*** LOG addons.xpi: Skipping unavailable install location app-system-local
*** LOG addons.xpi: Skipping unavailable install location app-system-share
*** LOG addons.xpi: checkForChanges
*** LOG addons.xpi: No changes found
=> #<Selenium::WebDriver::Driver:0x..fbe37f7d8 browser=:firefox>
irb(main):003:0>
答案 0 :(得分:2)
您的Firefox个人资料正在检查启动时的附加组件。当我在Windows中开发基于Ruby的Selenium测试时,我曾经经常收到这条消息。切换到Mac OS X然后转到Ubuntu实际上似乎为我解决了这个问题,但由于这有点极端,你可以做一个解决方法。
首先,您需要在Firefox中设置一个新的配置文件,该配置文件在启动时不会检查加载项。以下是您需要在该配置文件上设置的选项的主题:link。以下是Mozilla关于如何使用Firefox Profile Manager的参考资料,以备不时之需:link
然后在你的Ruby代码中,你有这样的东西:
driver = Selenium::WebDriver.for :firefox
您需要添加一个选项,告诉Webdriver使用哪个配置文件。最终会看起来像这样:
driver = Selenium::WebDriver.for :firefox, :profile => "selenium_testing"
(只需将“selenium_testing”替换为您为新配置文件命名的内容。)
然后,您应该能够在没有所有这些恼人的警告的情况下启动Firefox。
答案 1 :(得分:1)
我通过将Firefox升级到旧版本解决了这个问题(与Selenium-WebDriver配合得很好)。在我的情况下,我不得不降级回Firefox 18
,此版本与Selenium 2.27