Skip to content

Commit 84003f7

Browse files
add complete implementation for app sdk in python sdk
1 parent 38a57d6 commit 84003f7

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

selenium/lambdatest_selenium_driver/smartui_app_snapshot.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,17 @@ def _process_screenshot_capture(self, driver: WebDriver, screenshot_name: str,
233233

234234
def _process_upload_options(self, upload_request: UploadSnapshotRequest, options: Dict[str, str]):
235235
"""Process upload-related options."""
236+
self._set_upload_chunk_options(upload_request, options)
236237
self._set_navigation_options(upload_request, options)
237238
upload_request.crop_footer = "false"
238239
upload_request.crop_status_bar = "false"
240+
241+
def _set_upload_chunk_options(self, upload_request: UploadSnapshotRequest, options: Dict[str, str]):
242+
"""Set upload chunk related options."""
243+
#get boolean value for upload chunk from options
244+
upload_chunk = self._parse_boolean_option(options, "uploadChunk", False)
245+
if upload_chunk:
246+
upload_request.upload_chunk = "true"
239247

240248
def _set_navigation_options(self, upload_request: UploadSnapshotRequest, options: Dict[str, str]):
241249
"""Set navigation bar and status bar height options."""
@@ -255,11 +263,12 @@ def _handle_screenshot_capture(self, driver: WebDriver, screenshot_name: str,
255263
temp_dir = tempfile.mkdtemp(prefix=f"smartui_{screenshot_name}_")
256264

257265
try:
266+
full_page_util = FullPageScreenshotUtil(
267+
driver, temp_dir, config.test_type, config.precise_scroll
268+
)
269+
upload_request.device_name = full_page_util.device_name
258270
if config.full_page:
259271
# Full-page screenshot
260-
full_page_util = FullPageScreenshotUtil(
261-
driver, temp_dir, config.test_type, config.precise_scroll
262-
)
263272
result = full_page_util.capture_full_page_screenshot(page_count)
264273
screenshots = result["screenshots"]
265274
self._validate_screenshots(screenshots)
@@ -297,7 +306,6 @@ def _upload_single_screenshot(self, screenshot_path: str, upload_request: Upload
297306
def _upload_multiple_screenshots(self, screenshots: List[str], upload_request: UploadSnapshotRequest):
298307
"""Upload multiple screenshots as chunks."""
299308
total_screenshots = len(screenshots)
300-
upload_request.upload_chunk = "true"
301309

302310
# Upload all but last screenshot
303311
for i in range(total_screenshots - 1):

utils/lambdatest_sdk_utils/app_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# API URLs
1111
SMARTUI_CLIENT_API_URL = os.getenv("SMARTUI_CLIENT_API_URL", "https://api.lambdatest.com/visualui/1.0")
1212
SMARTUI_UPLOAD_URL = os.getenv("SMARTUI_UPLOAD_URL", "https://api.lambdatest.com/")
13-
TEST_TYPE = "lambdatest-python-app-sdk"
13+
TEST_TYPE = "lambdatest-java-app-sdk"
1414

1515
# Routes
1616
SMARTUI_AUTH_ROUTE = "/token/verify"
@@ -124,7 +124,7 @@ def upload_screenshot(screenshot_path: str, upload_request: UploadSnapshotReques
124124
Exception: If upload fails
125125
"""
126126
try:
127-
url = get_upload_host_url() + SMARTUI_UPLOAD_SCREENSHOT_ROUTE
127+
url = get_host_url() + SMARTUI_UPLOAD_SCREENSHOT_ROUTE
128128

129129
# Prepare multipart form data
130130
with open(screenshot_path, 'rb') as f:

utils/lambdatest_sdk_utils/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class UploadSnapshotRequest:
6161
status_bar_height: Optional[str] = None
6262
crop_footer: Optional[str] = "false"
6363
crop_status_bar: Optional[str] = "false"
64+
project_type: Optional[str] = None
6465

6566
def to_dict(self):
6667
"""Convert to dictionary for multipart form data."""
@@ -97,6 +98,8 @@ def to_dict(self):
9798
data["cropFooter"] = self.crop_footer
9899
if self.crop_status_bar:
99100
data["cropStatusBar"] = self.crop_status_bar
101+
if self.project_type:
102+
data["projectType"] = self.project_type
100103

101104
return data
102105

0 commit comments

Comments
 (0)