@@ -1948,6 +1948,90 @@ def __highlight_with_js(self, selector, loops, o_bs):
1948
1948
def __highlight_with_jquery (self , selector , loops , o_bs ):
1949
1949
js_utils .highlight_with_jquery (self .driver , selector , loops , o_bs )
1950
1950
1951
+ def press_up_arrow (self , selector = "html" , times = 1 , by = By .CSS_SELECTOR ):
1952
+ """ Simulates pressing the UP Arrow on the keyboard.
1953
+ By default, "html" will be used as the CSS Selector target.
1954
+ You can specify how many times in-a-row the action happens. """
1955
+ if times < 1 :
1956
+ return
1957
+ element = self .wait_for_element_present (selector )
1958
+ self .__demo_mode_highlight_if_active (selector , by )
1959
+ if not self .demo_mode :
1960
+ self .__scroll_to_element (element , selector , by )
1961
+ for i in range (int (times )):
1962
+ try :
1963
+ element .send_keys (Keys .ARROW_UP )
1964
+ except Exception :
1965
+ self .wait_for_ready_state_complete ()
1966
+ element = self .wait_for_element_visible (selector )
1967
+ element .send_keys (Keys .ARROW_UP )
1968
+ time .sleep (0.01 )
1969
+ if self .slow_mode :
1970
+ time .sleep (0.1 )
1971
+
1972
+ def press_down_arrow (self , selector = "html" , times = 1 , by = By .CSS_SELECTOR ):
1973
+ """ Simulates pressing the DOWN Arrow on the keyboard.
1974
+ By default, "html" will be used as the CSS Selector target.
1975
+ You can specify how many times in-a-row the action happens. """
1976
+ if times < 1 :
1977
+ return
1978
+ element = self .wait_for_element_present (selector )
1979
+ self .__demo_mode_highlight_if_active (selector , by )
1980
+ if not self .demo_mode :
1981
+ self .__scroll_to_element (element , selector , by )
1982
+ for i in range (int (times )):
1983
+ try :
1984
+ element .send_keys (Keys .ARROW_DOWN )
1985
+ except Exception :
1986
+ self .wait_for_ready_state_complete ()
1987
+ element = self .wait_for_element_visible (selector )
1988
+ element .send_keys (Keys .ARROW_DOWN )
1989
+ time .sleep (0.01 )
1990
+ if self .slow_mode :
1991
+ time .sleep (0.1 )
1992
+
1993
+ def press_left_arrow (self , selector = "html" , times = 1 , by = By .CSS_SELECTOR ):
1994
+ """ Simulates pressing the LEFT Arrow on the keyboard.
1995
+ By default, "html" will be used as the CSS Selector target.
1996
+ You can specify how many times in-a-row the action happens. """
1997
+ if times < 1 :
1998
+ return
1999
+ element = self .wait_for_element_present (selector )
2000
+ self .__demo_mode_highlight_if_active (selector , by )
2001
+ if not self .demo_mode :
2002
+ self .__scroll_to_element (element , selector , by )
2003
+ for i in range (int (times )):
2004
+ try :
2005
+ element .send_keys (Keys .ARROW_LEFT )
2006
+ except Exception :
2007
+ self .wait_for_ready_state_complete ()
2008
+ element = self .wait_for_element_visible (selector )
2009
+ element .send_keys (Keys .ARROW_LEFT )
2010
+ time .sleep (0.01 )
2011
+ if self .slow_mode :
2012
+ time .sleep (0.1 )
2013
+
2014
+ def press_right_arrow (self , selector = "html" , times = 1 , by = By .CSS_SELECTOR ):
2015
+ """ Simulates pressing the RIGHT Arrow on the keyboard.
2016
+ By default, "html" will be used as the CSS Selector target.
2017
+ You can specify how many times in-a-row the action happens. """
2018
+ if times < 1 :
2019
+ return
2020
+ element = self .wait_for_element_present (selector )
2021
+ self .__demo_mode_highlight_if_active (selector , by )
2022
+ if not self .demo_mode :
2023
+ self .__scroll_to_element (element , selector , by )
2024
+ for i in range (int (times )):
2025
+ try :
2026
+ element .send_keys (Keys .ARROW_RIGHT )
2027
+ except Exception :
2028
+ self .wait_for_ready_state_complete ()
2029
+ element = self .wait_for_element_visible (selector )
2030
+ element .send_keys (Keys .ARROW_RIGHT )
2031
+ time .sleep (0.01 )
2032
+ if self .slow_mode :
2033
+ time .sleep (0.1 )
2034
+
1951
2035
def scroll_to (self , selector , by = By .CSS_SELECTOR , timeout = None ):
1952
2036
''' Fast scroll to destination '''
1953
2037
if not timeout :
@@ -1987,6 +2071,7 @@ def slow_scroll_to(self, selector, by=By.CSS_SELECTOR, timeout=None):
1987
2071
self .__slow_scroll_to_element (element )
1988
2072
1989
2073
def scroll_to_top (self ):
2074
+ """ Scroll to the top of the page. """
1990
2075
scroll_script = "window.scrollTo(0, 0);"
1991
2076
try :
1992
2077
self .execute_script (scroll_script )
@@ -1996,6 +2081,7 @@ def scroll_to_top(self):
1996
2081
return False
1997
2082
1998
2083
def scroll_to_bottom (self ):
2084
+ """ Scroll to the bottom of the page. """
1999
2085
scroll_script = "window.scrollTo(0, 10000);"
2000
2086
try :
2001
2087
self .execute_script (scroll_script )
0 commit comments