12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
- from typing import TYPE_CHECKING , List , Optional , Tuple , TypeVar
15
+ from typing import TYPE_CHECKING , List , Optional , Tuple , TypeVar , Union
16
16
17
17
from selenium import webdriver
18
18
21
21
from appium .webdriver .webelement import WebElement
22
22
23
23
if TYPE_CHECKING :
24
+ # noinspection PyUnresolvedReferences
24
25
from appium .webdriver .webdriver import WebDriver
25
26
26
- T = TypeVar ('T' , bound = 'WebDriver' )
27
+ T = TypeVar ('T' , bound = Union [ 'WebDriver' , 'ActionHelpers' ] )
27
28
28
29
29
30
class ActionHelpers (webdriver .Remote ):
30
31
31
- def scroll (self , origin_el : WebElement , destination_el : WebElement , duration : Optional [int ] = None ) -> T :
32
+ def scroll (self : T , origin_el : WebElement , destination_el : WebElement , duration : Optional [int ] = None ) -> T :
32
33
"""Scrolls from one element to another
33
34
34
35
Args:
35
- originalEl (`appium.webdriver.webelement.WebElement`) : the element from which to being scrolling
36
- destinationEl (`appium.webdriver.webelement.WebElement`) : the element to scroll to
37
- duration (int) : a duration after pressing originalEl and move the element to destinationEl.
36
+ origin_el : the element from which to being scrolling
37
+ destination_el : the element to scroll to
38
+ duration: a duration after pressing originalEl and move the element to destinationEl.
38
39
Default is 600 ms for W3C spec. Zero for MJSONWP.
39
40
40
41
Usage:
@@ -55,12 +56,12 @@ def scroll(self, origin_el: WebElement, destination_el: WebElement, duration: Op
55
56
action .press (origin_el ).wait (duration ).move_to (destination_el ).release ().perform ()
56
57
return self
57
58
58
- def drag_and_drop (self , origin_el : WebElement , destination_el : WebElement ) -> T :
59
+ def drag_and_drop (self : T , origin_el : WebElement , destination_el : WebElement ) -> T :
59
60
"""Drag the origin element to the destination element
60
61
61
62
Args:
62
- originEl (`appium.webdriver.webelement.WebElement`) : the element to drag
63
- destinationEl (`appium.webdriver.webelement.WebElement`) : the element to drag to
63
+ origin_el : the element to drag
64
+ destination_el : the element to drag to
64
65
65
66
Returns:
66
67
`appium.webdriver.webelement.WebElement`
@@ -69,7 +70,7 @@ def drag_and_drop(self, origin_el: WebElement, destination_el: WebElement) -> T:
69
70
action .long_press (origin_el ).move_to (destination_el ).release ().perform ()
70
71
return self
71
72
72
- def tap (self , positions : List [Tuple [int , int ]], duration : Optional [int ] = None ) -> T :
73
+ def tap (self : T , positions : List [Tuple [int , int ]], duration : Optional [int ] = None ) -> T :
73
74
"""Taps on an particular place with up to five fingers, holding for a
74
75
certain time
75
76
@@ -108,7 +109,7 @@ def tap(self, positions: List[Tuple[int, int]], duration: Optional[int] = None)
108
109
ma .perform ()
109
110
return self
110
111
111
- def swipe (self , start_x : int , start_y : int , end_x : int , end_y : int , duration : int = 0 ) -> T :
112
+ def swipe (self : T , start_x : int , start_y : int , end_x : int , end_y : int , duration : int = 0 ) -> T :
112
113
"""Swipe from one point to another point, for an optional duration.
113
114
114
115
Args:
@@ -135,7 +136,7 @@ def swipe(self, start_x: int, start_y: int, end_x: int, end_y: int, duration: in
135
136
action .perform ()
136
137
return self
137
138
138
- def flick (self , start_x : int , start_y : int , end_x : int , end_y : int ) -> T :
139
+ def flick (self : T , start_x : int , start_y : int , end_x : int , end_y : int ) -> T :
139
140
"""Flick from one point to another point.
140
141
141
142
Args:
0 commit comments