Skip to content

Commit 6a74dc4

Browse files
authored
Merge pull request #39 from LambdaTest/stage
Stage
2 parents fbee619 + bea4487 commit 6a74dc4

File tree

7 files changed

+38
-13
lines changed

7 files changed

+38
-13
lines changed

selenium/lambdatest_selenium_driver/smartui.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
2-
from lambdatest_sdk_utils import is_smartui_enabled,fetch_dom_serializer,post_snapshot
2+
import uuid
3+
from lambdatest_sdk_utils import is_smartui_enabled,fetch_dom_serializer,post_snapshot,get_snapshot_status
34
from lambdatest_sdk_utils import setup_logger,get_logger
45

56

@@ -34,13 +35,30 @@ def smartui_snapshot(driver, name,options={}):
3435

3536
# Post the dom to smartui endpoint
3637
dom['name'] = name
37-
res = post_snapshot(dom,'lambdatest-selenium-driver',options=options)
38+
if 'sync' in options and options['sync'] is True:
39+
options['contextId'] = str(uuid.uuid4())
40+
res = post_snapshot(dom,'lambdatest-selenium-driver',options=options)
3841

39-
if res and res.get('data') and res['data'].get('warnings') and len(res['data']['warnings']) != 0:
40-
for warning in res['data']['warnings']:
41-
logger.warn(warning)
42+
if res and res.get('data') and res['data'].get('warnings') and len(res['data']['warnings']) != 0:
43+
for warning in res['data']['warnings']:
44+
logger.warn(warning)
4245

43-
logger.info(f'Snapshot captured {name}')
46+
logger.info(f'Snapshot captured {name}')
47+
timeout= 600
48+
if 'timeout' in options and options['timeout'] is not None:
49+
timeout = options['timeout']
50+
if timeout > 900 or timeout < 30:
51+
timeout=600
52+
logger.warn("Timeout value is not valid, allowed range is 30-900 seconds. Defaulting to 600 seconds.")
53+
return get_snapshot_status(name,options['contextId'],timeout)
54+
else:
55+
res = post_snapshot(dom,'lambdatest-selenium-driver',options=options)
56+
57+
if res and res.get('data') and res['data'].get('warnings') and len(res['data']['warnings']) != 0:
58+
for warning in res['data']['warnings']:
59+
logger.warn(warning)
60+
61+
logger.info(f'Snapshot captured {name}')
4462
except Exception as e:
4563
logger.error(f'SmartUI snapshot failed "${name}"')
4664
logger.error(e)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.0.4'
1+
__version__ = '1.0.6'

selenium/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setup(
99
name="lambdatest-selenium-driver",
10-
version="1.0.5",
10+
version="1.0.6",
1111
author="LambdaTest <[email protected]>",
1212
description="Python Selenium SDK for testing with Smart UI",
1313
long_description=long_description,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from lambdatest_sdk_utils.constants import get_smart_ui_server_address
22
from lambdatest_sdk_utils.logger import log_level,setup_logger,get_logger
3-
from lambdatest_sdk_utils.rest import post_snapshot,is_smartui_enabled,fetch_dom_serializer
3+
from lambdatest_sdk_utils.rest import post_snapshot,is_smartui_enabled,fetch_dom_serializer,get_snapshot_status
44
from lambdatest_sdk_utils.version import __version__

utils/lambdatest_sdk_utils/rest.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,12 @@ def post_snapshot(snapshot,pkg,**kwargs):
5050
logger.debug(f'post snapshot failed : {msg}')
5151
raise Exception(f'post snapshot failed')
5252

53-
53+
def get_snapshot_status(snapshot_name,context_id,timeout):
54+
try:
55+
response = requests.get(f'{get_smart_ui_server_address()}/snapshot/status?contextId={context_id}&snapshotName={snapshot_name}&pollTimeout={timeout}')
56+
response.raise_for_status()
57+
return response.json()
58+
except Exception as e:
59+
logger.debug(f'get snapshot status failed : {e}')
60+
raise Exception(f'get snapshot status failed')
61+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.0.3'
1+
__version__ = '1.0.4'

utils/setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
from setuptools import setup, find_packages
2-
import lambdatest_sdk_utils
32

43
setup(
54
name="lambdatest-sdk-utils",
6-
version="1.0.3",
5+
version="1.0.4",
76
author="LambdaTest <[email protected]>",
87
description="SDK utils",
98
long_description="SDK utils for lambdatest",

0 commit comments

Comments
 (0)