2014-02-27 13 views
0

다음 코드를 사용하여 오른쪽 클릭으로 메뉴를 표시합니다 (Selenium 컨텍스트 메뉴에서).dojo가 만든 중첩 된 div에 watir이 (가) 접근 할 수 없습니다. 네이티브 상호 작용을 Preform 할 수 없습니다.

# encoding: utf-8 
require 'watir-webdriver' 
b = Watir::Browser.new 


b.goto 'localhost:8080/swbadmin' 
b.text_field(:name => 'wb_username').set 'admin' 
b.text_field(:name => 'wb_password').set 'webbuilder' 
b.button(:text => 'Login').click 

a = b.div(:class => 'dijitTreeNodeContainer').div(:class => 'dijitTreeIsRoot').div(:class => 'dijitTreeRow').span(:class => 'dijitTreeContent') 
c= a.span(:text => 'tst') 
c.right_click 

dijitTreeNodeContainer는 도장에 의해 만들어진 것입니다. 모든 정보가로드 될 때까지 기다려야하므로 Watir :: wait.until {span (: text => 'tst'). visible?}을 사용하려고 시도했지만 작동하지 않습니다. 라인

c= a.span(:text => 'tst') 

및 c.click로, 나는 기본 TreeContent을 클릭 할 수 있어요,하지만 난 마우스 오른쪽 버튼으로 클릭하거나 DOUBLE_CLICK으로 할 때, 예외를 throw하지 않고이 코드 (..cannot 기본 미리 형성 이 윈도우에서 파이어 폭스 - 상호 작용 ...) 이는 HTML 코드

<div id="dijit_layout_AccordionPane_0" class="dijitContentPane dijitAccordionContainer-child dijitAccordionContainer-dijitContentPane dijitContentPaneSingleChild" selected="true" dojotype="dijit.layout.AccordionPane" widgetid="dijit_layout_AccordionPane_0" title="" style="width: 238px; height: 76.5px;"> 
<div url="/swbadmin/jsp/Tree.jsp?id=mtree" jsid="mtreeStore" dojotype="dojo.data.ItemFileWriteStore"></div> 
<div childrenattrs="children" rootid="root" store="mtreeStore" jsid="mtreeModel" dojotype="dijit.tree.ForestStoreModel"></div> 
<div id="mtree" class="dojoDndSource dojoDndTarget dojoDndContainer dijitTree" role="presentation" widgetid="mtree" tabindex="0" _dijitmenumtreemenu="1" style="width: 238px; height: 76.5px;"> 
<div class="dijitInline dijitTreeIndent" data-dojo-attach-point="indentDetector" style="position: absolute; top: -9999px"></div> 
<div class="dijitTreeExpando dijitTreeExpandoLoading" data-dojo-attach-point="rootLoadingIndicator" style="display: none;"></div> 
<div class="dijitTreeContainer" role="presentation" data-dojo-attach-point="containerNode" style="width: 100%;"> 
<div id="dijit__TreeNode_0" class="dijitTreeIsRoot dijitTreeNode dijitTreeNodeLoaded dijitLoaded" role="presentation" style="background-position: 0px 0px;" widgetid="dijit__TreeNode_0"> 
<div class="dijitTreeRow" role="presentation" data-dojo-attach-point="rowNode" style="padding-left: 0px; display: none;"> 
<div class="dijitTreeNodeContainer" style="height: auto;" role="tree" data-dojo-attach-point="containerNode" aria-expanded="true" aria-multiselectable="true"> 
<div id="dijit__TreeNode_3" class="dijitTreeIsRoot dijitTreeNode dijitTreeNodeNotLoaded dijitNotLoaded" role="presentation" style="background-position: 0px 0px;" widgetid="dijit__TreeNode_3"> 
<div class="dijitTreeRow dijitTreeRowSelected" role="presentation" data-dojo-attach-point="rowNode" title="" style="padding-left: 0px;"> 
<span class="dijitInline dijitTreeExpando dijitTreeExpandoClosed" role="presentation" data-dojo-attach-point="expandoNode"></span> 
<span class="dijitExpandoText" role="presentation" data-dojo-attach-point="expandoNodeText">+</span> 
<span class="dijitTreeContent" role="presentation" data-dojo-attach-point="contentNode"> 
<span class="dijitInline dijitIcon dijitTreeIcon swbIconWebSite" data-dojo-attach-point="iconNode" role="presentation"></span> 
<span class="dijitTreeLabel" aria-selected="true" tabindex="-1" role="treeitem" data-dojo-attach-point="labelNode,focusNode" aria-expanded="false">Demo</span> 
</span> 
</div> 
<div class="dijitTreeNodeContainer" style="display: none;" role="presentation" data-dojo-attach-point="containerNode"></div> 
</div> 
<div id="dijit__TreeNode_4" class="dijitTreeIsRoot dijitTreeNode dijitTreeNodeLoaded dijitLoaded" role="presentation" style="background-position: 0px 0px;" widgetid="dijit__TreeNode_4"> 
<div class="dijitTreeRow" role="presentation" data-dojo-attach-point="rowNode" title="" style="padding-left: 0px;"> 
<span class="dijitInline dijitTreeExpando dijitTreeExpandoClosed" role="presentation" data-dojo-attach-point="expandoNode"></span> 
<span class="dijitExpandoText" role="presentation" data-dojo-attach-point="expandoNodeText">+</span> 
<span class="dijitTreeContent" role="presentation" data-dojo-attach-point="contentNode"> 
<span class="dijitInline dijitIcon dijitTreeIcon swbIconWebSiteU" data-dojo-attach-point="iconNode" role="presentation"></span> 
<span class="dijitTreeLabel" aria-selected="false" tabindex="-1" role="treeitem" data-dojo-attach-point="labelNode,focusNode" aria-expanded="false">tst</span> 
</span> 
</div> 
<div class="dijitTreeNodeContainer" style="height: auto; display: none;" role="group" data-dojo-attach-point="containerNode"> 
</div> 
</div> 
</div> 
</div> 
</div> 
</div> 
</div> 
</div> 

답변

0

당신은 당신이 사용중인 브라우저 언급하지 않았다입니까? 이 경우 Chrome을 대신 생성 해보십시오.

b = Watir::Browser.new :chrome 

Firefox를 계속 사용해야하는 경우 기본 이벤트를 사용하지 않도록 설정하십시오.

profile = Selenium::WebDriver::Firefox::Profile.new 
profile.native_events = false 
b = Watir::Browser.new :firefox, :profile => profile 
+0

예, Firefox를 사용하고 있습니다. 이미 기본 이벤트를 사용하지 않도록 설정했지만 작동하지 않았습니다. 그리고 다른 문제는 내가 텍스트 'tst'와 함께 두 번째 트리 노드에 도달 할 수 없다는 것입니다. – Yut