@@ -84,11 +84,11 @@ def test_default_wait
84
84
end
85
85
86
86
def test_default_timeout_for_http_client
87
- @ driver || = android_mock_create_session
87
+ driver = android_mock_create_session
88
88
89
89
assert_equal 999_999 , @core . http_client . open_timeout
90
90
assert_equal 999_999 , @core . http_client . read_timeout
91
- uri = @ driver. send ( :bridge ) . http . send ( :server_url )
91
+ uri = driver . send ( :bridge ) . http . send ( :server_url )
92
92
assert @core . direct_connect
93
93
assert_equal 'http' , uri . scheme
94
94
assert_equal '127.0.0.1' , uri . host
@@ -623,45 +623,105 @@ def test_listener_with_custom_listener_elements
623
623
stub_request ( :post , "#{ SESSION } /element" )
624
624
. with ( body : { using : 'id' , value : 'example' } . to_json )
625
625
. to_return ( headers : HEADER , status : 200 , body : {
626
- value : { ELEMENT : 'element_id_parent' } , sessionId : SESSION , status : 0
626
+ value : { :: Appium :: Core :: Element :: ELEMENT_KEY => 'element_id_parent' } , sessionId : SESSION , status : 0
627
627
} . to_json )
628
628
el = driver . find_element id : 'example'
629
629
assert_requested :post , "#{ SESSION } /element" , times : 1
630
- assert_equal el . class . name , ' Appium::Core::Element'
630
+ assert_equal :: Appium ::Core ::Element , el . class
631
631
632
632
# No W3C, but can call via '::Appium::Core::Element'
633
633
stub_request ( :get , "#{ SESSION } /element/element_id_parent/displayed" )
634
634
. to_return ( headers : HEADER , status : 200 , body : { value : { } } . to_json )
635
635
el . displayed?
636
636
assert_requested :get , "#{ SESSION } /element/element_id_parent/displayed" , times : 1
637
- assert_equal el . class . name , ' Appium::Core::Element'
637
+ assert_equal :: Appium ::Core ::Element , el . class
638
638
639
639
stub_request ( :post , "#{ SESSION } /element/element_id_parent/element" )
640
640
. with ( body : { using : 'id' , value : 'example2' } . to_json )
641
641
. to_return ( headers : HEADER , status : 200 , body : {
642
- value : { ELEMENT : 'element_id_children' } , sessionId : SESSION , status : 0
642
+ value : { :: Appium :: Core :: Element :: ELEMENT_KEY => 'element_id_children' } , sessionId : SESSION , status : 0
643
643
} . to_json )
644
644
c_el = el . find_element id : 'example2'
645
645
assert_requested :post , "#{ SESSION } /element/element_id_parent/element" , times : 1
646
- assert_equal c_el . class . name , ' Appium::Core::Element'
646
+ assert_equal :: Appium ::Core ::Element , c_el . class
647
647
648
648
# elements
649
649
stub_request ( :post , "#{ SESSION } /elements" )
650
650
. with ( body : { using : 'id' , value : 'example' } . to_json )
651
651
. to_return ( headers : HEADER , status : 200 , body : {
652
- value : [ { ELEMENT : 'element_id_parent' } ] , sessionId : SESSION , status : 0
652
+ value : [ { :: Appium :: Core :: Element :: ELEMENT_KEY => 'element_id_parent' } ] , sessionId : SESSION , status : 0
653
653
} . to_json )
654
654
els = driver . find_elements id : 'example'
655
+ assert_requested :post , "#{ SESSION } /elements" , times : 1
656
+ assert_equal ::Appium ::Core ::Element , els . first . class
657
+
658
+ stub_request ( :post , "#{ SESSION } /element/element_id_parent/elements" )
659
+ . with ( body : { using : 'id' , value : 'example2' } . to_json )
660
+ . to_return ( headers : HEADER , status : 200 , body : {
661
+ value : [ { ::Appium ::Core ::Element ::ELEMENT_KEY => 'element_id_children' } ] ,
662
+ sessionId : SESSION , status : 0
663
+ } . to_json )
664
+ c_el = els . first . find_elements id : 'example2'
665
+ assert_requested :post , "#{ SESSION } /element/element_id_parent/elements" , times : 1
666
+ assert_equal ::Appium ::Core ::Element , c_el . first . class
667
+ end
668
+
669
+ def test_elements
670
+ driver = android_mock_create_session
671
+
672
+ # element
673
+ stub_request ( :post , "#{ SESSION } /element" )
674
+ . with ( body : { using : 'id' , value : 'example' } . to_json )
675
+ . to_return ( headers : HEADER , status : 200 , body : {
676
+ value : { ::Appium ::Core ::Element ::ELEMENT_KEY => 'element_id_parent' } , sessionId : SESSION , status : 0
677
+ } . to_json )
678
+ el = driver . find_element id : 'example'
655
679
assert_requested :post , "#{ SESSION } /element" , times : 1
656
- assert_equal els . first . class . name , 'Appium::Core::Element'
680
+ assert_equal ::Appium ::Core ::Element , el . class
681
+
682
+ # No W3C, but can call via '::Appium::Core::Element'
683
+ stub_request ( :get , "#{ SESSION } /element/element_id_parent/displayed" )
684
+ . to_return ( headers : HEADER , status : 200 , body : { value : { } } . to_json )
685
+ el . displayed?
686
+ assert_requested :get , "#{ SESSION } /element/element_id_parent/displayed" , times : 1
687
+ assert_equal ::Appium ::Core ::Element , el . class
688
+
689
+ stub_request ( :post , "#{ SESSION } /element/element_id_parent/element" )
690
+ . with ( body : { using : 'id' , value : 'example2' } . to_json )
691
+ . to_return ( headers : HEADER , status : 200 , body : {
692
+ value : { ::Appium ::Core ::Element ::ELEMENT_KEY => 'element_id_children' } , sessionId : SESSION , status : 0
693
+ } . to_json )
694
+ c_el = el . find_element id : 'example2'
695
+ assert_requested :post , "#{ SESSION } /element/element_id_parent/element" , times : 1
696
+ assert_equal ::Appium ::Core ::Element , c_el . class
697
+
698
+ # elements
699
+ stub_request ( :post , "#{ SESSION } /elements" )
700
+ . with ( body : { using : 'id' , value : 'example' } . to_json )
701
+ . to_return ( headers : HEADER , status : 200 , body : {
702
+ value : [ { ::Appium ::Core ::Element ::ELEMENT_KEY => 'element_id_parent' } ] , sessionId : SESSION , status : 0
703
+ } . to_json )
704
+ els = driver . find_elements id : 'example'
705
+ assert_requested :post , "#{ SESSION } /elements" , times : 1
706
+ assert_equal ::Appium ::Core ::Element , els . first . class
657
707
658
708
stub_request ( :post , "#{ SESSION } /element/element_id_parent/elements" )
659
709
. with ( body : { using : 'id' , value : 'example2' } . to_json )
660
- . to_return ( headers : HEADER , status : 200 , body : { value : [ { ELEMENT : 'element_id_children' } ] ,
661
- sessionId : SESSION , status : 0 } . to_json )
710
+ . to_return ( headers : HEADER , status : 200 , body : {
711
+ value : [ { ::Appium ::Core ::Element ::ELEMENT_KEY => 'element_id_children' } ] ,
712
+ sessionId : SESSION , status : 0
713
+ } . to_json )
662
714
c_el = els . first . find_elements id : 'example2'
663
715
assert_requested :post , "#{ SESSION } /element/element_id_parent/elements" , times : 1
664
- assert_equal c_el . first . class . name , 'Appium::Core::Element'
716
+ assert_equal ::Appium ::Core ::Element , c_el . first . class
717
+ end
718
+
719
+ def test_convert_element
720
+ driver = android_mock_create_session
721
+ response = { 'element-6066-11e4-a52e-4f735466cecf' => 'test-element-id' , 'ELEMENT' => 'test-element-id' }
722
+ e = driver . convert_to_element response
723
+ assert_equal 'test-element-id' , e . id
724
+ assert_equal ::Appium ::Core ::Element , e . class
665
725
end
666
726
end
667
727
end
0 commit comments