Watir 및 Watir-WebDriver와 동시에 작업 중이며 일부 클래스를 다시 열고 일부 메서드를 다시 정의하여 호환성을 높이려고합니다. 나는 설명 할 수없는 이상한 행동을했다. 나는 무슨 일이 일어나고 있는지 이해하려고 노력하고있다.Ruby 클래스를 다시 열 때 이상한 문제가 발생했습니다.
이것은 Windows에서만 사용할 수있는 watir-1.7.1에서 발생합니다.
루비 1.8.7-P330
RUBYOPT =
require 'watir'
Watir::ElementCollections.class_eval do
def new_method
end
end
>ruby open-classes-watir1.rb
open-classes-watir1.rb:3: uninitialized constant Watir::ElementCollections (NameError)
1. 왜 루비가 유효한 클래스를 재개에 대해 불평 않습니다 테스트
-rubygems?
element_collections.rb:
module Watir
#...
class ElementCollections
include Enumerable
#...
end
end
을하지만 그게 전부가 아니에요 :
는 문제의 클래스는 다음과 같습니다!
테스트 2.
require 'watir'
Watir::IE.class_eval do
end
Watir::ElementCollections.class_eval do # Requires the magic incantation above
def new_method
end
end
>ruby open-classes-watir2.rb
그것은이 검은 마법과 지금 잘 실행 : 이제이보세요. Watir과 :: IE는 다음과 같습니다
ie-class.rb:
module Watir
class IE
include WaitHelper
include Exception
include Container
include PageContainer
#...
end
end
이유는 무엇입니까?
나는 "watir/ie"가 필요하다. –
'watir/element_collections'도 필요하다. – DKroot