File tree Expand file tree Collapse file tree 6 files changed +23
-2
lines changed Expand file tree Collapse file tree 6 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -493,6 +493,9 @@ def attrs(*attr_names)
493493 var xpath = '';
494494 var pos, tempitem2;
495495
496+ if (el.getRootNode && el.getRootNode() instanceof ShadowRoot) {
497+ return ": Shadow DOM element - no XPath :"
498+ };
496499 while(el !== xml.documentElement) {
497500 pos = 0;
498501 tempitem2 = el;
Original file line number Diff line number Diff line change @@ -271,5 +271,10 @@ $(function() {
271271 } ) ;
272272 $ ( '#multiple-file, #hidden_file' ) . change ( function ( e ) {
273273 $ ( 'body' ) . append ( $ ( '<p class="file_change">File input changed</p>' ) ) ;
274- } )
274+ } ) ;
275+
276+ var shadow = document . querySelector ( '#shadow' ) . attachShadow ( { mode : 'open' } ) ;
277+ var span = document . createElement ( 'span' ) ;
278+ span . textContent = 'The things we do in the shadows' ;
279+ shadow . appendChild ( span ) ;
275280} ) ;
Original file line number Diff line number Diff line change 409409 element = @session . find ( :link , 'Second Link' )
410410 expect ( @session . find ( :xpath , element . path ) ) . to eq ( element )
411411 end
412+
413+ it 'reports when element in shadow dom' , requires : [ :shadow_dom ] do
414+ @session . visit ( '/with_js' )
415+ shadow = @session . find ( :css , '#shadow' )
416+ element = @session . evaluate_script ( <<~JS , shadow )
417+ (function(root){
418+ return root.shadowRoot.querySelector('span');
419+ })(arguments[0])
420+ JS
421+ expect ( element . path ) . to eq ": Shadow DOM element - no XPath :"
422+ end
412423 end
413424
414425 describe '#trigger' , requires : %i[ js trigger ] do
Original file line number Diff line number Diff line change 152152 < p > This is an HTML5 draggable element.</ p >
153153 </ div >
154154
155+ < div id ="shadow "> </ div >
155156 < script type ="text/javascript ">
156157 // a javascript comment
157158 var aVar = 123 ;
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ class TestClass
88end
99
1010Capybara ::SpecHelper . run_specs TestClass . new , 'DSL' , capybara_skip : %i[
11- js modals screenshot frames windows send_keys server hover about_scheme psc download css driver scroll spatial html_validation
11+ js modals screenshot frames windows send_keys server hover about_scheme psc download css driver scroll spatial html_validation shadow_dom
1212] do |example |
1313 case example . metadata [ :full_description ]
1414 when /has_css\? should support case insensitive :class and :id options/
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ module TestSessions
2727 scroll
2828 spatial
2929 html_validation
30+ shadow_dom
3031]
3132Capybara ::SpecHelper . run_specs TestSessions ::RackTest , 'RackTest' , capybara_skip : skipped_tests do |example |
3233 case example . metadata [ :full_description ]
You can’t perform that action at this time.
0 commit comments