2015-04-05 30 views
1

我正在使用以下代碼片段來創建Internet Explorer瀏覽器並執行一些測試。由於下面給出的例外,我無法創建ie瀏覽器。我該如何解決?watir無法創建Internet Explorer瀏覽器 - 啓用保護模式問題

require 'rubygems' 
require 'watir-webdriver' 
require 'phantomjs' 

client = Selenium::WebDriver::Remote::Http::Default.new 
client.timeout = 300 

browser = Watir::Browser.new :ie, :http_client => client 
browser.goto "some url" 

錯誤 -

Started InternetExplorerDriver server (32-bit) 
2.29.0.0 
Listening on port 5555 
C:/code/ruby/lib/ruby/gems/1.8/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/response.rb:51:in `assert_ok': Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (Selenium::WebDriver::Error::NoSuchDriverError) 
     from C:/code/ruby/lib/ruby/gems/1.8/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/response.rb:15:in `initialize' 
     from C:/code/ruby/lib/ruby/gems/1.8/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/common.rb:59:in `new' 
     from C:/code/ruby/lib/ruby/gems/1.8/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/common.rb:59:in `create_response' 
     from C:/code/ruby/lib/ruby/gems/1.8/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/default.rb:66:in `request' 
     from C:/code/ruby/lib/ruby/gems/1.8/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call' 
     from C:/code/ruby/lib/ruby/gems/1.8/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:629:in `raw_execute' 
     from C:/code/ruby/lib/ruby/gems/1.8/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:98:in `create_session' 
     from C:/code/ruby/lib/ruby/gems/1.8/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:68:in `initialize' 
     from C:/code/ruby/lib/ruby/gems/1.8/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/ie/bridge.rb:47:in `initialize' 
     from C:/code/ruby/lib/ruby/gems/1.8/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/common/driver.rb:35:in `new' 
     from C:/code/ruby/lib/ruby/gems/1.8/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/common/driver.rb:35:in `for' 
     from C:/code/ruby/lib/ruby/gems/1.8/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver.rb:67:in `for' 
     from C:/code/ruby/lib/ruby/gems/1.8/gems/watir-webdriver-0.6.2/lib/watir-webdriver/browser.rb:46:in `initialize' 
     from web-test.rb:8:in `new' 

回答

1

我找不到任何的Ruby代碼,這將解決這個問題。但是,我知道,你可以改變你的IE設置來解決這個問題 - http://jimevansmusic.blogspot.com/2012/08/youre-doing-it-wrong-protected-mode-and.html

如何設置保護模式設置

在IE中,從工具菜單(或更高版本工具欄上的齒輪圖標) ,選擇「Internet選項」。轉到安全選項卡。在每個區域對話框的底部,您應該看到一個標記爲「啓用保護模式」的複選框。對於每個區域,將複選框的值設置爲相同的值(選中或取消選中)。以下是供參考的對話框:

Here's the dialog for reference:

相關問題