1
1
from time import sleep
2
2
3
- from selenium .webdriver import ActionChains
3
+ from selenium .webdriver import ActionChains , Keys
4
4
from selenium .webdriver .common .by import By
5
5
from selenium .webdriver .common .actions .wheel_input import ScrollOrigin
6
6
@@ -9,8 +9,8 @@ def test_can_scroll_to_element(driver):
9
9
driver .get ("https://selenium.dev/selenium/web/scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html" )
10
10
11
11
iframe = driver .find_element (By .TAG_NAME , "iframe" )
12
- ActionChains (driver )\
13
- .scroll_to_element (iframe )\
12
+ ActionChains (driver ) \
13
+ .scroll_to_element (iframe ) \
14
14
.perform ()
15
15
16
16
assert _in_viewport (driver , iframe )
@@ -21,8 +21,8 @@ def test_can_scroll_from_viewport_by_amount(driver):
21
21
22
22
footer = driver .find_element (By .TAG_NAME , "footer" )
23
23
delta_y = footer .rect ['y' ]
24
- ActionChains (driver )\
25
- .scroll_by_amount (0 , delta_y )\
24
+ ActionChains (driver ) \
25
+ .scroll_by_amount (0 , delta_y ) \
26
26
.perform ()
27
27
28
28
sleep (0.5 )
@@ -34,8 +34,8 @@ def test_can_scroll_from_element_by_amount(driver):
34
34
35
35
iframe = driver .find_element (By .TAG_NAME , "iframe" )
36
36
scroll_origin = ScrollOrigin .from_element (iframe )
37
- ActionChains (driver )\
38
- .scroll_from_origin (scroll_origin , 0 , 200 )\
37
+ ActionChains (driver ) \
38
+ .scroll_from_origin (scroll_origin , 0 , 200 ) \
39
39
.perform ()
40
40
41
41
sleep (0.5 )
@@ -49,8 +49,8 @@ def test_can_scroll_from_element_with_offset_by_amount(driver):
49
49
50
50
footer = driver .find_element (By .TAG_NAME , "footer" )
51
51
scroll_origin = ScrollOrigin .from_element (footer , 0 , - 50 )
52
- ActionChains (driver )\
53
- .scroll_from_origin (scroll_origin , 0 , 200 )\
52
+ ActionChains (driver ) \
53
+ .scroll_from_origin (scroll_origin , 0 , 200 ) \
54
54
.perform ()
55
55
56
56
sleep (0.5 )
@@ -65,8 +65,8 @@ def test_can_scroll_from_viewport_with_offset_by_amount(driver):
65
65
66
66
scroll_origin = ScrollOrigin .from_viewport (10 , 10 )
67
67
68
- ActionChains (driver )\
69
- .scroll_from_origin (scroll_origin , 0 , 200 )\
68
+ ActionChains (driver ) \
69
+ .scroll_from_origin (scroll_origin , 0 , 200 ) \
70
70
.perform ()
71
71
72
72
sleep (0.5 )
@@ -84,3 +84,13 @@ def _in_viewport(driver, element):
84
84
"window.pageYOffset&&t+o>window.pageXOffset"
85
85
)
86
86
return driver .execute_script (script , element )
87
+
88
+
89
+ def test_scroll_down_with_arrow_keys (firefox_driver ):
90
+ firefox_driver .get ("https://www.selenium.dev/" )
91
+ body = firefox_driver .find_element (By .TAG_NAME , "body" )
92
+ prev_height = body .size ['height' ]
93
+ body .send_keys (Keys .ARROW_DOWN )
94
+ new_height = body .size ['height' ]
95
+ assert new_height == prev_height
96
+ firefox_driver .close ()
0 commit comments