Skip to content

Commit 3868dd1

Browse files
feat: fix formatting
1 parent 914841c commit 3868dd1

File tree

6 files changed

+32
-110
lines changed

6 files changed

+32
-110
lines changed

appium/options/flutter_integration/flutter_element_wait_timeout_option.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,5 @@ def flutter_element_wait_timeout(self, value: Union[timedelta, int]) -> None:
4747
"""
4848
self.set_capability(
4949
FLUTTER_ELEMENT_WAIT_TIMEOUT,
50-
(
51-
int(value.total_seconds() * 1000)
52-
if isinstance(value, timedelta)
53-
else value
54-
),
50+
(int(value.total_seconds() * 1000) if isinstance(value, timedelta) else value),
5551
)

appium/options/flutter_integration/flutter_server_launch_timeout_option.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,5 @@ def flutter_server_launch_timeout(self, value: Union[timedelta, int]) -> None:
4848
"""
4949
self.set_capability(
5050
FLUTTER_SERVER_LAUNCH_TIMEOUT,
51-
(
52-
int(value.total_seconds() * 1000)
53-
if isinstance(value, timedelta)
54-
else value
55-
),
51+
(int(value.total_seconds() * 1000) if isinstance(value, timedelta) else value),
5652
)

appium/webdriver/extensions/flutter_integration/flutter_commands.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
from typing import Any, Dict, Optional, Tuple, Union
1717

1818
from appium.common.helper import encode_file_to_base64
19-
from appium.webdriver.extensions.flutter_integration.scroll_directions import (
20-
ScrollDirection,
21-
)
19+
from appium.webdriver.extensions.flutter_integration.scroll_directions import ScrollDirection
2220
from appium.webdriver.flutter_finder import FlutterFinder
2321
from appium.webdriver.webdriver import WebDriver
2422
from appium.webdriver.webelement import WebElement
@@ -75,9 +73,7 @@ def wait_for_invisible(
7573

7674
# flutter action commands
7775

78-
def perform_double_click(
79-
self, element: WebElement, offset: Optional[Tuple[int, int]] = None
80-
) -> None:
76+
def perform_double_click(self, element: WebElement, offset: Optional[Tuple[int, int]] = None) -> None:
8177
"""
8278
Performs a double-click on the given element, with an optional offset.
8379
@@ -93,9 +89,7 @@ def perform_double_click(
9389
opts['offset'] = {'x': offset[0], 'y': offset[1]}
9490
self.execute_flutter_command('doubleClick', opts)
9591

96-
def perform_long_press(
97-
self, element: WebElement, offset: Optional[Tuple[int, int]] = None
98-
) -> None:
92+
def perform_long_press(self, element: WebElement, offset: Optional[Tuple[int, int]] = None) -> None:
9993
"""
10094
Performs a long press on the given element, with an optional offset.
10195
@@ -122,9 +116,7 @@ def perform_drag_and_drop(self, source: WebElement, target: WebElement) -> None:
122116
Returns:
123117
None:
124118
"""
125-
self.execute_flutter_command(
126-
'dragAndDrop', {'source': source, 'target': target}
127-
)
119+
self.execute_flutter_command('dragAndDrop', {'source': source, 'target': target})
128120

129121
def scroll_till_visible(
130122
self,
@@ -167,9 +159,7 @@ def inject_mock_image(self, value: str) -> str:
167159
base64_encoded_image = encode_file_to_base64(value)
168160
else:
169161
base64_encoded_image = value
170-
return self.execute_flutter_command(
171-
'injectImage', {'base64Image': base64_encoded_image}
172-
)
162+
return self.execute_flutter_command('injectImage', {'base64Image': base64_encoded_image})
173163

174164
def activate_injected_image(self, image_id: str) -> None:
175165
"""

test/functional/flutter_integration/commands_test.py

Lines changed: 17 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,11 @@ def test_scroll_till_visible_command(self) -> None:
5050
first_element = self.flutter_command.scroll_till_visible(java_text_finder)
5151
assert first_element.get_attribute('displayed') == 'true'
5252

53-
second_element = self.flutter_command.scroll_till_visible(
54-
protractor_text_finder
55-
)
53+
second_element = self.flutter_command.scroll_till_visible(protractor_text_finder)
5654
assert second_element.get_attribute('displayed') == 'true'
5755
assert first_element.get_attribute('displayed') == 'false'
5856

59-
first_element = self.flutter_command.scroll_till_visible(
60-
java_text_finder, ScrollDirection.UP
61-
)
57+
first_element = self.flutter_command.scroll_till_visible(java_text_finder, ScrollDirection.UP)
6258
assert second_element.get_attribute('displayed') == 'false'
6359
assert first_element.get_attribute('displayed') == 'true'
6460

@@ -73,9 +69,7 @@ def test_scroll_till_visible_with_scroll_params_command(self) -> None:
7369
'dragDuration': 35,
7470
}
7571
first_element = self.flutter_command.scroll_till_visible(
76-
FlutterFinder.by_text('Playwright'),
77-
scroll_direction=ScrollDirection.DOWN,
78-
**scroll_params
72+
FlutterFinder.by_text('Playwright'), scroll_direction=ScrollDirection.DOWN, **scroll_params
7973
)
8074
assert first_element.get_attribute('displayed') == 'true'
8175

@@ -89,18 +83,14 @@ def test_double_click_command(self) -> None:
8983

9084
self.flutter_command.perform_double_click(double_tap_button)
9185
assert (
92-
self.driver.find_element(
93-
AppiumBy.FLUTTER_INTEGRATION_TEXT_CONTAINING, 'Successful'
94-
).text
86+
self.driver.find_element(AppiumBy.FLUTTER_INTEGRATION_TEXT_CONTAINING, 'Successful').text
9587
== 'Double Tap Successful'
9688
)
9789

9890
self.driver.find_element(AppiumBy.FLUTTER_INTEGRATION_TEXT, 'Ok').click()
9991
self.flutter_command.perform_double_click(double_tap_button, (10, 2))
10092
assert (
101-
self.driver.find_element(
102-
AppiumBy.FLUTTER_INTEGRATION_TEXT_CONTAINING, 'Successful'
103-
).text
93+
self.driver.find_element(AppiumBy.FLUTTER_INTEGRATION_TEXT_CONTAINING, 'Successful').text
10494
== 'Double Tap Successful'
10595
)
10696

@@ -109,72 +99,39 @@ def test_double_click_command(self) -> None:
10999
def test_long_press_command(self) -> None:
110100
self.__open_screen('Long Press')
111101

112-
long_press_button = self.driver.find_element(
113-
AppiumBy.FLUTTER_INTEGRATION_KEY, 'long_press_button'
114-
)
102+
long_press_button = self.driver.find_element(AppiumBy.FLUTTER_INTEGRATION_KEY, 'long_press_button')
115103
self.flutter_command.perform_long_press(long_press_button)
116104

117-
success_pop_up = self.driver.find_element(
118-
AppiumBy.FLUTTER_INTEGRATION_TEXT, 'It was a long press'
119-
)
105+
success_pop_up = self.driver.find_element(AppiumBy.FLUTTER_INTEGRATION_TEXT, 'It was a long press')
120106
assert success_pop_up.text == 'It was a long press'
121107
assert success_pop_up.is_displayed() == True
122108

123109
def test_drag_and_drop_command(self) -> None:
124110
self.__open_screen('Drag & Drop')
125111

126-
drag_element = self.driver.find_element(
127-
AppiumBy.FLUTTER_INTEGRATION_KEY, 'drag_me'
128-
)
129-
drop_element = self.driver.find_element(
130-
AppiumBy.FLUTTER_INTEGRATION_KEY, 'drop_zone'
131-
)
112+
drag_element = self.driver.find_element(AppiumBy.FLUTTER_INTEGRATION_KEY, 'drag_me')
113+
drop_element = self.driver.find_element(AppiumBy.FLUTTER_INTEGRATION_KEY, 'drop_zone')
132114
self.flutter_command.perform_drag_and_drop(drag_element, drop_element)
133-
assert (
134-
self.driver.find_element(
135-
AppiumBy.FLUTTER_INTEGRATION_TEXT, 'The box is dropped'
136-
).is_displayed()
137-
== True
138-
)
115+
assert self.driver.find_element(AppiumBy.FLUTTER_INTEGRATION_TEXT, 'The box is dropped').is_displayed() == True
139116

140117
def test_camera_mocking(self) -> None:
141118
self.__open_screen('Image Picker')
142119

143-
success_qr_file_path = os.path.join(
144-
os.path.dirname(os.path.abspath(__file__)), 'file', 'success_qr.png'
145-
)
146-
second_qr_file_path = os.path.join(
147-
os.path.dirname(os.path.abspath(__file__)), 'file', 'second_qr.png'
148-
)
120+
success_qr_file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'file', 'success_qr.png')
121+
second_qr_file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'file', 'second_qr.png')
149122

150123
image_id = self.flutter_command.inject_mock_image(success_qr_file_path)
151124
self.flutter_command.inject_mock_image(second_qr_file_path)
152-
self.driver.find_element(
153-
AppiumBy.FLUTTER_INTEGRATION_KEY, 'capture_image'
154-
).click()
125+
self.driver.find_element(AppiumBy.FLUTTER_INTEGRATION_KEY, 'capture_image').click()
155126
self.driver.find_element(AppiumBy.FLUTTER_INTEGRATION_TEXT, 'PICK').click()
156-
assert (
157-
self.driver.find_element(
158-
AppiumBy.FLUTTER_INTEGRATION_TEXT, 'SecondInjectedImage'
159-
).is_displayed()
160-
== True
161-
)
127+
assert self.driver.find_element(AppiumBy.FLUTTER_INTEGRATION_TEXT, 'SecondInjectedImage').is_displayed() == True
162128

163129
self.flutter_command.activate_injected_image(image_id)
164-
self.driver.find_element(
165-
AppiumBy.FLUTTER_INTEGRATION_KEY, 'capture_image'
166-
).click()
130+
self.driver.find_element(AppiumBy.FLUTTER_INTEGRATION_KEY, 'capture_image').click()
167131
self.driver.find_element(AppiumBy.FLUTTER_INTEGRATION_TEXT, 'PICK').click()
168-
assert (
169-
self.driver.find_element(
170-
AppiumBy.FLUTTER_INTEGRATION_TEXT, 'Success!'
171-
).is_displayed()
172-
== True
173-
)
132+
assert self.driver.find_element(AppiumBy.FLUTTER_INTEGRATION_TEXT, 'Success!').is_displayed() == True
174133

175134
def __open_screen(self, screen_name: str) -> None:
176135
self.driver.find_element(AppiumBy.FLUTTER_INTEGRATION_TEXT, 'Login').click()
177-
element = self.flutter_command.scroll_till_visible(
178-
FlutterFinder.by_text(screen_name)
179-
)
136+
element = self.flutter_command.scroll_till_visible(FlutterFinder.by_text(screen_name))
180137
element.click()

test/functional/flutter_integration/finder_test.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,8 @@ def test_by_flutter_key(self) -> None:
3131
assert user_name_field.text == 'admin123'
3232

3333
def test_by_flutter_type(self) -> None:
34-
login_button = self.driver.find_element(
35-
AppiumBy.FLUTTER_INTEGRATION_TYPE, 'ElevatedButton'
36-
)
37-
assert (
38-
login_button.find_element(AppiumBy.FLUTTER_INTEGRATION_TYPE, 'Text').text
39-
== 'Login'
40-
)
34+
login_button = self.driver.find_element(AppiumBy.FLUTTER_INTEGRATION_TYPE, 'ElevatedButton')
35+
assert login_button.find_element(AppiumBy.FLUTTER_INTEGRATION_TYPE, 'Text').text == 'Login'
4136

4237
def test_by_flutter_text(self) -> None:
4338
login_button = self.driver.find_element(*LOGIN_BUTTON_FINDER.as_args())
@@ -50,19 +45,13 @@ def test_by_flutter_text(self) -> None:
5045
def test_by_flutter_text_containing(self) -> None:
5146
login_button = self.driver.find_element(*LOGIN_BUTTON_FINDER.as_args())
5247
login_button.click()
53-
vertical_swipe_label = self.driver.find_element(
54-
AppiumBy.FLUTTER_INTEGRATION_TEXT_CONTAINING, 'Vertical'
55-
)
48+
vertical_swipe_label = self.driver.find_element(AppiumBy.FLUTTER_INTEGRATION_TEXT_CONTAINING, 'Vertical')
5649
assert vertical_swipe_label.text == 'Vertical Swiping'
5750

5851
def test_by_flutter_semantics_label(self) -> None:
5952
login_button = self.driver.find_element(*LOGIN_BUTTON_FINDER.as_args())
6053
login_button.click()
61-
element = self.flutter_command.scroll_till_visible(
62-
FlutterFinder.by_text('Lazy Loading')
63-
)
54+
element = self.flutter_command.scroll_till_visible(FlutterFinder.by_text('Lazy Loading'))
6455
element.click()
65-
message_field = self.driver.find_element(
66-
AppiumBy.FLUTTER_INTEGRATION_SEMANTICS_LABEL, 'message_field'
67-
)
56+
message_field = self.driver.find_element(AppiumBy.FLUTTER_INTEGRATION_SEMANTICS_LABEL, 'message_field')
6857
assert message_field.text == 'Hello world'

test/unit/webdriver/flutter_integration/flutter_search_context_test.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ def test_find_element_by_flutter_semantics_label(self):
9292
appium_command('/session/1234567890/element'),
9393
body='{"value": {"element-6066-11e4-a52e-4f735466cecf": "element-id"}}',
9494
)
95-
el = driver.find_element(
96-
AppiumBy.FLUTTER_INTEGRATION_SEMANTICS_LABEL, 'Flutter UI Semantics Label'
97-
)
95+
el = driver.find_element(AppiumBy.FLUTTER_INTEGRATION_SEMANTICS_LABEL, 'Flutter UI Semantics Label')
9896

9997
d = get_httpretty_request_body(httpretty.last_request())
10098
assert d['using'] == '-flutter semantics label'
@@ -110,9 +108,7 @@ def test_find_elements_by_flutter_semantics_label(self):
110108
body='{"value": [{"element-6066-11e4-a52e-4f735466cecf": "child-element-id1"}, '
111109
'{"element-6066-11e4-a52e-4f735466cecf": "child-element-id2"}]}',
112110
)
113-
els = driver.find_elements(
114-
AppiumBy.FLUTTER_INTEGRATION_SEMANTICS_LABEL, 'Flutter UI Semantics Label'
115-
)
111+
els = driver.find_elements(AppiumBy.FLUTTER_INTEGRATION_SEMANTICS_LABEL, 'Flutter UI Semantics Label')
116112

117113
d = get_httpretty_request_body(httpretty.last_request())
118114
assert d['using'] == '-flutter semantics label'
@@ -160,9 +156,7 @@ def test_find_element_by_flutter_text_containing(self):
160156
appium_command('/session/1234567890/element'),
161157
body='{"value": {"element-6066-11e4-a52e-4f735466cecf": "element-id"}}',
162158
)
163-
el = driver.find_element(
164-
AppiumBy.FLUTTER_INTEGRATION_TEXT_CONTAINING, 'Flutter UI Partial Text'
165-
)
159+
el = driver.find_element(AppiumBy.FLUTTER_INTEGRATION_TEXT_CONTAINING, 'Flutter UI Partial Text')
166160

167161
d = get_httpretty_request_body(httpretty.last_request())
168162
assert d['using'] == '-flutter text containing'

0 commit comments

Comments
 (0)