@@ -494,21 +494,21 @@ class TestWebElementClicking:
494
494
async def test_click_using_js_success (self , web_element ):
495
495
"""Test successful JavaScript click."""
496
496
# Mock element visibility and click success
497
- web_element ._is_element_visible = AsyncMock (return_value = True )
497
+ web_element .is_visible = AsyncMock (return_value = True )
498
498
web_element .scroll_into_view = AsyncMock ()
499
- web_element ._execute_script = AsyncMock (
499
+ web_element .execute_script = AsyncMock (
500
500
return_value = {'result' : {'result' : {'value' : True }}}
501
501
)
502
502
503
503
await web_element .click_using_js ()
504
504
505
505
web_element .scroll_into_view .assert_called_once ()
506
- web_element ._is_element_visible .assert_called_once ()
506
+ web_element .is_visible .assert_called_once ()
507
507
508
508
@pytest .mark .asyncio
509
509
async def test_click_using_js_not_visible (self , web_element ):
510
510
"""Test JavaScript click when element is not visible."""
511
- web_element ._is_element_visible = AsyncMock (return_value = False )
511
+ web_element .is_visible = AsyncMock (return_value = False )
512
512
web_element .scroll_into_view = AsyncMock ()
513
513
514
514
with pytest .raises (ElementNotVisible ):
@@ -517,9 +517,9 @@ async def test_click_using_js_not_visible(self, web_element):
517
517
@pytest .mark .asyncio
518
518
async def test_click_using_js_not_interactable (self , web_element ):
519
519
"""Test JavaScript click when element is not interactable."""
520
- web_element ._is_element_visible = AsyncMock (return_value = True )
520
+ web_element .is_visible = AsyncMock (return_value = True )
521
521
web_element .scroll_into_view = AsyncMock ()
522
- web_element ._execute_script = AsyncMock (
522
+ web_element .execute_script = AsyncMock (
523
523
return_value = {'result' : {'result' : {'value' : False }}}
524
524
)
525
525
@@ -539,7 +539,7 @@ async def test_click_using_js_option_element(self, option_element):
539
539
async def test_click_success (self , web_element ):
540
540
"""Test successful mouse click."""
541
541
bounds = [0 , 0 , 100 , 0 , 100 , 100 , 0 , 100 ] # Rectangle coordinates
542
- web_element ._is_element_visible = AsyncMock (return_value = True )
542
+ web_element .is_visible = AsyncMock (return_value = True )
543
543
web_element .scroll_into_view = AsyncMock ()
544
544
web_element ._connection_handler .execute_command .side_effect = [
545
545
{'result' : {'model' : {'content' : bounds }}}, # bounds
@@ -557,7 +557,7 @@ async def test_click_success(self, web_element):
557
557
@pytest .mark .asyncio
558
558
async def test_click_not_visible (self , web_element ):
559
559
"""Test click when element is not visible."""
560
- web_element ._is_element_visible = AsyncMock (return_value = False )
560
+ web_element .is_visible = AsyncMock (return_value = False )
561
561
562
562
with pytest .raises (ElementNotVisible ):
563
563
await web_element .click ()
@@ -574,7 +574,7 @@ async def test_click_option_element(self, option_element):
574
574
@pytest .mark .asyncio
575
575
async def test_click_bounds_fallback_to_js (self , web_element ):
576
576
"""Test click falls back to JS bounds when CDP bounds fail."""
577
- web_element ._is_element_visible = AsyncMock (return_value = True )
577
+ web_element .is_visible = AsyncMock (return_value = True )
578
578
web_element .scroll_into_view = AsyncMock ()
579
579
580
580
# First call (bounds) raises KeyError, second call (JS bounds) succeeds
@@ -686,61 +686,61 @@ class TestWebElementVisibility:
686
686
@pytest .mark .asyncio
687
687
async def test_is_element_visible_true (self , web_element ):
688
688
"""Test _is_element_visible returns True."""
689
- web_element ._execute_script = AsyncMock (
689
+ web_element .execute_script = AsyncMock (
690
690
return_value = {'result' : {'result' : {'value' : True }}}
691
691
)
692
692
693
- result = await web_element ._is_element_visible ()
693
+ result = await web_element .is_visible ()
694
694
assert result is True
695
695
696
696
@pytest .mark .asyncio
697
697
async def test_is_element_visible_false (self , web_element ):
698
698
"""Test _is_element_visible returns False."""
699
- web_element ._execute_script = AsyncMock (
699
+ web_element .execute_script = AsyncMock (
700
700
return_value = {'result' : {'result' : {'value' : False }}}
701
701
)
702
702
703
- result = await web_element ._is_element_visible ()
703
+ result = await web_element .is_visible ()
704
704
assert result is False
705
705
706
706
@pytest .mark .asyncio
707
707
async def test_is_element_on_top_true (self , web_element ):
708
708
"""Test _is_element_on_top returns True."""
709
- web_element ._execute_script = AsyncMock (
709
+ web_element .execute_script = AsyncMock (
710
710
return_value = {'result' : {'result' : {'value' : True }}}
711
711
)
712
712
713
- result = await web_element ._is_element_on_top ()
713
+ result = await web_element .is_on_top ()
714
714
assert result is True
715
715
716
716
@pytest .mark .asyncio
717
717
async def test_is_element_on_top_false (self , web_element ):
718
718
"""Test _is_element_on_top returns False."""
719
- web_element ._execute_script = AsyncMock (
719
+ web_element .execute_script = AsyncMock (
720
720
return_value = {'result' : {'result' : {'value' : False }}}
721
721
)
722
722
723
- result = await web_element ._is_element_on_top ()
723
+ result = await web_element .is_on_top ()
724
724
assert result is False
725
725
726
726
@pytest .mark .asyncio
727
727
async def test_is_element_interactable_true (self , web_element ):
728
728
"""Test _is_element_interactable returns True."""
729
- web_element ._execute_script = AsyncMock (
729
+ web_element .execute_script = AsyncMock (
730
730
return_value = {'result' : {'result' : {'value' : True }}}
731
731
)
732
732
733
- result = await web_element ._is_element_interactable ()
733
+ result = await web_element .is_interactable ()
734
734
assert result is True
735
735
736
736
@pytest .mark .asyncio
737
737
async def test_is_element_interactable_false (self , web_element ):
738
738
"""Test _is_element_interactable returns False."""
739
- web_element ._execute_script = AsyncMock (
739
+ web_element .execute_script = AsyncMock (
740
740
return_value = {'result' : {'result' : {'value' : False }}}
741
741
)
742
742
743
- result = await web_element ._is_element_interactable ()
743
+ result = await web_element .is_interactable ()
744
744
assert result is False
745
745
746
746
@@ -750,21 +750,21 @@ class TestWebElementWaitUntil:
750
750
@pytest .mark .asyncio
751
751
async def test_wait_until_visible_success (self , web_element ):
752
752
"""Test wait_until succeeds when element becomes visible."""
753
- web_element ._is_element_visible = AsyncMock (side_effect = [False , True ])
753
+ web_element .is_visible = AsyncMock (side_effect = [False , True ])
754
754
755
755
with patch ('asyncio.sleep' ) as mock_sleep , \
756
756
patch ('asyncio.get_event_loop' ) as mock_loop :
757
757
mock_loop .return_value .time .side_effect = [0 , 0.5 ]
758
758
759
759
await web_element .wait_until (is_visible = True , timeout = 2 )
760
760
761
- assert web_element ._is_element_visible .call_count == 2
761
+ assert web_element .is_visible .call_count == 2
762
762
mock_sleep .assert_called_once_with (0.5 )
763
763
764
764
@pytest .mark .asyncio
765
765
async def test_wait_until_visible_timeout (self , web_element ):
766
766
"""Test wait_until raises WaitElementTimeout when visibility not met."""
767
- web_element ._is_element_visible = AsyncMock (return_value = False )
767
+ web_element .is_visible = AsyncMock (return_value = False )
768
768
769
769
with patch ('asyncio.sleep' ) as mock_sleep , \
770
770
patch ('asyncio.get_event_loop' ) as mock_loop :
@@ -780,16 +780,16 @@ async def test_wait_until_visible_timeout(self, web_element):
780
780
@pytest .mark .asyncio
781
781
async def test_wait_until_interactable_success (self , web_element ):
782
782
"""Test wait_until succeeds when element becomes interactable."""
783
- web_element ._is_element_interactable = AsyncMock (return_value = True )
783
+ web_element .is_interactable = AsyncMock (return_value = True )
784
784
785
785
await web_element .wait_until (is_interactable = True , timeout = 1 )
786
786
787
- web_element ._is_element_interactable .assert_called_once ()
787
+ web_element .is_interactable .assert_called_once ()
788
788
789
789
@pytest .mark .asyncio
790
790
async def test_wait_until_interactable_timeout (self , web_element ):
791
791
"""Test wait_until raises WaitElementTimeout when not interactable."""
792
- web_element ._is_element_interactable = AsyncMock (return_value = False )
792
+ web_element .is_interactable = AsyncMock (return_value = False )
793
793
794
794
with patch ('asyncio.sleep' ) as mock_sleep , \
795
795
patch ('asyncio.get_event_loop' ) as mock_loop :
@@ -805,8 +805,8 @@ async def test_wait_until_interactable_timeout(self, web_element):
805
805
@pytest .mark .asyncio
806
806
async def test_wait_until_visible_and_interactable (self , web_element ):
807
807
"""Test wait_until requires both conditions when both are True."""
808
- web_element ._is_element_visible = AsyncMock (side_effect = [False , True ])
809
- web_element ._is_element_interactable = AsyncMock (side_effect = [False , True ])
808
+ web_element .is_visible = AsyncMock (side_effect = [False , True ])
809
+ web_element .is_interactable = AsyncMock (side_effect = [False , True ])
810
810
811
811
with patch ('asyncio.sleep' ) as mock_sleep , \
812
812
patch ('asyncio.get_event_loop' ) as mock_loop :
@@ -816,8 +816,8 @@ async def test_wait_until_visible_and_interactable(self, web_element):
816
816
is_visible = True , is_interactable = True , timeout = 2
817
817
)
818
818
819
- assert web_element ._is_element_visible .call_count == 2
820
- assert web_element ._is_element_interactable .call_count == 2
819
+ assert web_element .is_visible .call_count == 2
820
+ assert web_element .is_interactable .call_count == 2
821
821
mock_sleep .assert_called_once_with (0.5 )
822
822
823
823
@pytest .mark .asyncio
@@ -880,7 +880,7 @@ async def test_execute_script(self, web_element):
880
880
expected_response = {'result' : {'result' : {'value' : 'DIV' }}}
881
881
web_element ._connection_handler .execute_command .return_value = expected_response
882
882
883
- result = await web_element ._execute_script (script , return_by_value = True )
883
+ result = await web_element .execute_script (script , return_by_value = True )
884
884
885
885
assert result == expected_response
886
886
expected_command = RuntimeCommands .call_function_on (
@@ -1086,7 +1086,7 @@ async def test_text_property_with_malformed_html(self, web_element):
1086
1086
async def test_click_with_zero_hold_time (self , web_element ):
1087
1087
"""Test click with zero hold time."""
1088
1088
bounds = [0 , 0 , 50 , 0 , 50 , 50 , 0 , 50 ]
1089
- web_element ._is_element_visible = AsyncMock (return_value = True )
1089
+ web_element .is_visible = AsyncMock (return_value = True )
1090
1090
web_element .scroll_into_view = AsyncMock ()
1091
1091
web_element ._connection_handler .execute_command .side_effect = [
1092
1092
{'result' : {'model' : {'content' : bounds }}},
0 commit comments