可以在Watir的Firefox浏览器中安装扩展吗?

Mat*_*att 4 ruby selenium watir watir-webdriver selenium-webdriver

我正在尝试在包含大量广告的网页上使用Watir,这确实会减慢我的测试速度.为什么当Watir启动Firefox时,我的扩展程序(Adblock等)不能继续使用,是否可以安装它们?

Pur*_*rus 6

是的,你可以做到.让我们假设你想要使用Firebug扩展..

首先下载Firebug xpi文件,然后使用以下代码:

profile = Selenium::WebDriver::Firefox::Profile.new
profile.add_extension "../path/to/firebug.xpi"
b = Watir::Browser.new :firefox, :profile => profile
Run Code Online (Sandbox Code Playgroud)