@@ -33,7 +33,7 @@ class Bridge
33
33
34
34
class << self
35
35
attr_reader :extra_commands
36
- attr_writer :locator_converter
36
+ attr_writer :element_class , : locator_converter
37
37
38
38
def add_command ( name , verb , url , &block )
39
39
@extra_commands ||= { }
@@ -44,6 +44,10 @@ def add_command(name, verb, url, &block)
44
44
def locator_converter
45
45
@locator_converter ||= LocatorConverter . new
46
46
end
47
+
48
+ def element_class
49
+ @element_class ||= Element
50
+ end
47
51
end
48
52
49
53
#
@@ -432,7 +436,7 @@ def submit_element(element)
432
436
"e.initEvent('submit', true, true);\n " \
433
437
"if (form.dispatchEvent(e)) { HTMLFormElement.prototype.submit.call(form) }\n "
434
438
435
- execute_script ( script , Element ::ELEMENT_KEY => element )
439
+ execute_script ( script , Bridge . element_class ::ELEMENT_KEY => element )
436
440
rescue Error ::JavascriptError
437
441
raise Error ::UnsupportedOperationError , 'To submit an element, it must be nested inside a form element'
438
442
end
@@ -519,7 +523,7 @@ def element_value_of_css_property(element, prop)
519
523
#
520
524
521
525
def active_element
522
- Element . new self , element_id_from ( execute ( :get_active_element ) )
526
+ Bridge . element_class . new self , element_id_from ( execute ( :get_active_element ) )
523
527
end
524
528
525
529
alias switch_to_active_element active_element
@@ -539,7 +543,7 @@ def find_element_by(how, what, parent_ref = [])
539
543
execute :find_element , { } , { using : how , value : what . to_s }
540
544
end
541
545
542
- Element . new self , element_id_from ( id )
546
+ Bridge . element_class . new self , element_id_from ( id )
543
547
end
544
548
545
549
def find_elements_by ( how , what , parent_ref = [ ] )
@@ -557,7 +561,7 @@ def find_elements_by(how, what, parent_ref = [])
557
561
execute :find_elements , { } , { using : how , value : what . to_s }
558
562
end
559
563
560
- ids . map { |id | Element . new self , element_id_from ( id ) }
564
+ ids . map { |id | Bridge . element_class . new self , element_id_from ( id ) }
561
565
end
562
566
563
567
def shadow_root ( element )
@@ -631,7 +635,7 @@ def escaper
631
635
end
632
636
633
637
def commands ( command )
634
- command_list [ command ] || Bridge . extra_commands [ command ]
638
+ command_list [ command ] || Bridge . extra_commands [ command ]
635
639
end
636
640
637
641
def unwrap_script_result ( arg )
@@ -640,7 +644,7 @@ def unwrap_script_result(arg)
640
644
arg . map { |e | unwrap_script_result ( e ) }
641
645
when Hash
642
646
element_id = element_id_from ( arg )
643
- return Element . new ( self , element_id ) if element_id
647
+ return Bridge . element_class . new ( self , element_id ) if element_id
644
648
645
649
shadow_root_id = shadow_root_id_from ( arg )
646
650
return ShadowRoot . new self , shadow_root_id if shadow_root_id
@@ -652,7 +656,7 @@ def unwrap_script_result(arg)
652
656
end
653
657
654
658
def element_id_from ( id )
655
- id [ 'ELEMENT' ] || id [ Element ::ELEMENT_KEY ]
659
+ id [ 'ELEMENT' ] || id [ Bridge . element_class ::ELEMENT_KEY ]
656
660
end
657
661
658
662
def shadow_root_id_from ( id )
@@ -663,7 +667,6 @@ def prepare_capabilities_payload(capabilities)
663
667
capabilities = { alwaysMatch : capabilities } if !capabilities [ 'alwaysMatch' ] && !capabilities [ 'firstMatch' ]
664
668
{ capabilities : capabilities }
665
669
end
666
-
667
670
end # Bridge
668
671
end # Remote
669
672
end # WebDriver
0 commit comments