1

我的问题是关于修改默认配置文件设置以允许/拒绝我的网络应用程序访问麦克风和摄像头。这是代码-似乎被忽略了。

#!/usr/bin/ruby
require 'watir-webdriver'

profile = Selenium::WebDriver::Chrome::Profile.new
profile['content_settings.pattern_pairs.*,*.media-stream-mic'] = 1 
# if I put mysever.com into here (first asterix), the parsing must fail 
# as the '.' is used as delimiter by profile.rb - so *,* should work 

browser = Watir::Browser.new :chrome, :profile => profile 
browser.goto "http://webaudiodemos.appspot.com/input/index.html" 
# here a get media event is fired and the browser should proceed without(!)
# asking the user for permission - but the browser is always asking and 
# this element is not accessible for Watir (is it?).

我查看了仅进行解析的 profile.rb - 这也存在某种问题(请参阅内联评论)。

我也搜索了网络,但找不到任何东西。

霍尔格

4

1 回答 1

0
1. create a profile manually using the cmd :
 firefox -profilemanager
 set what you want on the browser of the new profile 
2.code example 

protected void initializeWebDriver() {  
        LoggerInfo.logger.info("Starting webdriver...");
        ProfilesIni allProfiles = new ProfilesIni();
        FirefoxProfile profile = allProfiles.getProfile("MyProfile");
//      FirefoxProfile profile = new FirefoxProfile();
        driver = new    DriverBuilder().using(Browser.FIREFOX).withFirefoxProfile(profile).build();
        LoggerInfo.logger.info("webdriver is up");
    }
于 2013-07-30T09:36:38.183 回答