2012-07-09 35 views
1

有人能解釋一下下面的錯誤意味着什麼?在`method_missing的「:未知的屬性或方法:'文件」(NoMethodError)

E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/ie-class.rb:488:in `method_missing': unknown property or method: `document' (NoMethodError) 
HRESULT error code:0x80010108 
    The object invoked has disconnected from its clients. 
from E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/ie-class.rb:488:in `document' 
from E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/page-container.rb:31:in `page' 
from E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/page-container.rb:55:in `html' 
from E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/xpath_locator.rb:7:in `xmlparser_document_object' 
from E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/xpath_locator.rb:30:in `elements_by_xpath' 
from E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/locator.rb:111:in `locate_elements_by_xpath_css_ole' 
from E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/locator.rb:209:in `locate' 
from E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/input_elements.rb:5:in `locate' 
from E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/element.rb:63:in `assert_exists' 
from E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/element.rb:414:in `perform_action' 
from E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/element.rb:269:in `click!' 
from E:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/element.rb:211:in `click' 

我使用一些代碼中,我需要做以下檢查 - 如果需要,標題被發現 - 這些附加的窗口,如果不是 - 通過URL連接窗口。

class Title 
    def initialize(title) 
    @@a = title 
    $ie=Watir::IE.attach(:title, @@a) 
    rescue Watir::Exception::NoMatchingWindowFoundException 
    puts ("could not find browser") 
    r.addtoReport(testReport, "check page element", "FAILED", "Page title not found") 
    end 
end 


if Title.new("Company") 
else 
    $ie=Watir::IE.attach(:title,"http://") 
end 

另一個變化是:

class Title 
    def initialize(title,title1) 
    @@a = title 
    @@b=title1 
    $ie=Watir::IE.attach(:title, @@a) 
    rescue Watir::Exception::NoMatchingWindowFoundException 
    puts ("could not find browser") 
    r.addtoReport(testReport, "check page element", "FAILED", "Page title not found") 
    else 
    $ie=Watir::IE.attach(:url, @@b) 
    end 
end 

Title.new("Company","http://") 

之前安裝窗口:

$ie.button(:xpath, "//input[contains(@onclick, \"path\")]").click 
+0

你有可能關閉IE之前的Watir已經完成了它? – 2012-07-09 14:14:18

+0

不,我沒有,它是開放的 – khris 2012-07-09 18:42:15

+0

它看起來像的同時單擊一個元素出現的錯誤消息。腳本還有其他部分嗎? – 2012-07-09 22:40:22

回答

0

對不起重振舊的文章,但這些信息必須是某個地方。 RE:這意味着watir沒有創建URL內容。 如果您指向本地主機,請嘗試以管理員身份運行測試。

+0

你已經發布了這個答案。 – Robert 2013-04-18 15:25:49

+0

我知道。它錯了嗎? 我這樣做是因爲每當我遇到這個錯誤時,我都會尋求幫助,這是搜索引擎顯示的第一個結果。所以我在這裏發佈了這個答案,因爲我解決了這個錯誤以管理員身份運行測試 但我知道這個問題在10個月前被問到了,所以我有點擔心在這樣一個老問題中發帖。 – 2013-06-03 23:00:21

相關問題