Class: Watir::ShadowRoot

Inherits:
Object
  • Object
show all
Includes:
Container, Exception, SearchContext, Waitable
Defined in:
lib/watir/shadow_root.rb

Instance Method Summary collapse

Methods included from Waitable

#wait_until, #wait_while

Methods included from SearchContext

#assert_exists, #check_condition, #element_call, #exists?, #unknown_exception, #wait_for_exists

Methods included from Container

#a, #abbr, #abbrs, #address, #addresses, #area, #areas, #article, #articles, #as, #aside, #asides, #audio, #audios, #b, #base, #bases, #bdi, #bdis, #bdo, #bdos, #blockquote, #blockquotes, #body, #bodys, #br, #brs, #bs, #button, #buttons, #canvas, #canvases, #caption, #captions, #checkbox, #checkboxes, #circle, #circles, #cite, #cites, #code, #codes, #col, #colgroup, #colgroups, #cols, #data, #datalist, #datalists, #datas, #date_field, #date_fields, #date_time_field, #date_time_fields, #dd, #dds, #defs, #defss, #del, #dels, #desc, #descs, #details, #detailses, #dfn, #dfns, #dialog, #dialogs, #div, #divs, #dl, #dls, #dt, #dts, #element, #elements, #ellipse, #ellipses, #em, #embed, #embeds, #ems, #field_set, #field_sets, #fieldset, #fieldsets, #figcaption, #figcaptions, #figure, #figures, #file_field, #file_fields, #font, #fonts, #footer, #footers, #foreign_object, #foreign_objects, #form, #forms, #frame, #frames, #frameset, #framesets, #g, #gs, #h1, #h1s, #h2, #h2s, #h3, #h3s, #h4, #h4s, #h5, #h5s, #h6, #h6s, #head, #header, #headers, #heads, #hidden, #hiddens, #hr, #hrs, #html, #htmls, #i, #iframe, #iframes, #image, #images, #img, #imgs, #input, #inputs, #ins, #inses, #is, #kbd, #kbds, #label, #labels, #legend, #legends, #li, #line, #linear_gradient, #linear_gradients, #lines, #link, #links, #lis, #main, #mains, #map, #maps, #mark, #marker, #markers, #marks, #meta, #metadata, #metadatas, #metas, #meter, #meters, #nav, #navs, #noscript, #noscripts, #object, #objects, #ol, #ols, #optgroup, #optgroups, #option, #options, #output, #outputs, #p, #param, #params, #path, #paths, #pattern, #patterns, #picture, #pictures, #polygon, #polygons, #polyline, #polylines, #pre, #pres, #progress, #progresses, #ps, #q, #qs, #radial_gradient, #radial_gradients, #radio, #radio_set, #radios, #rb, #rbs, #rect, #rects, #rp, #rps, #rt, #rtc, #rtcs, #rts, #rubies, #ruby, #s, #samp, #samps, #script, #scripts, #section, #sections, #select, #select_list, #select_lists, #selects, #small, #smalls, #source, #sources, #span, #spans, #ss, #stop, #stops, #strong, #strongs, #style, #styles, #sub, #subs, #summaries, #summary, #sup, #sups, #svg, #svgs, #switch, #switches, #symbol, #symbols, #table, #tables, #tbody, #tbodys, #td, #tds, #template, #templates, #text_field, #text_fields, #text_path, #text_paths, #textarea, #textareas, #tfoot, #tfoots, #th, #thead, #theads, #ths, #time, #times, #title, #titles, #tr, #track, #tracks, #trs, #tspan, #tspans, #u, #ul, #uls, #us, #use, #uses, #var, #vars, #video, #videos, #view, #views, #wbr, #wbrs

Methods included from JSSnippets

#execute_js

Constructor Details

#initialize(element) ⇒ ShadowRoot

Returns a new instance of ShadowRoot.



10
11
12
# File 'lib/watir/shadow_root.rb', line 10

def initialize(element)
  @query_scope = element
end

Instance Method Details

#browserObject



14
15
16
# File 'lib/watir/shadow_root.rb', line 14

def browser
  @query_scope.browser
end

#custom_messageObject



56
57
58
# File 'lib/watir/shadow_root.rb', line 56

def custom_message
  ''
end

#execute_script(script, *args, function_name: nil) ⇒ Object



27
28
29
# File 'lib/watir/shadow_root.rb', line 27

def execute_script(script, *args, function_name: nil)
  browser.execute_script(script, *args, function_name: function_name)
end

#locateObject



42
43
44
45
46
# File 'lib/watir/shadow_root.rb', line 42

def locate
  @shadow_root = @query_scope.wd.shadow_root
rescue Selenium::WebDriver::Error::NoSuchShadowRootError
  nil
end

#located?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/watir/shadow_root.rb', line 18

def located?
  !!@shadow_root
end

#reset!Object



38
39
40
# File 'lib/watir/shadow_root.rb', line 38

def reset!
  @shadow_root = nil
end

#selector_stringObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



52
53
54
# File 'lib/watir/shadow_root.rb', line 52

def selector_string
  "#{@query_scope.selector_string} --> shadow_root"
end

#stale?Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
# File 'lib/watir/shadow_root.rb', line 31

def stale?
  @shadow_root.find_elements(css: 'checking_stale_shadow_root')
  false
rescue Selenium::WebDriver::Error::DetachedShadowRootError
  true
end

#wdObject



22
23
24
25
# File 'lib/watir/shadow_root.rb', line 22

def wd
  assert_exists
  @shadow_root
end