Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions selenium/lambdatest_selenium_driver/smartui.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import json
from lambdatest_sdk_utils import is_smartui_enabled,fetch_dom_serializer,post_snapshot
from lambdatest_sdk_utils import get_pkg_name,setup_logger,get_logger


def smartui_snapshot(driver, name,**kwargs):
def smartui_snapshot(driver, name,options={}):
# setting up logger
setup_logger()
logger = get_logger()
Expand All @@ -17,10 +18,22 @@ def smartui_snapshot(driver, name,**kwargs):
driver.execute_script(resp['data']['dom'])

# Serialize and capture the DOM
dom = driver.execute_script("return {'dom':SmartUIDOM.serialize()}")
dom = driver.execute_script(
f"""
return {{
dom: SmartUIDOM.serialize({json.dumps(options)}),
url: document.URL
}}
"""
)

# Post the dom to smartui endpoint
post_snapshot(dom,name,get_pkg_name())
dom['name'] = name
res = post_snapshot(dom,get_pkg_name(),options=options)

if res and res.get('data') and res['data'].get('warnings') and len(res['data']['warnings']) != 0:
for warning in res['data']['warnings']:
logger.warn(warning)

logger.info(f'Snapshot captured {name}')
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion selenium/lambdatest_selenium_driver/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.0.1'
__version__ = '1.0.2'
2 changes: 1 addition & 1 deletion selenium/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name="lambdatest-selenium-driver",
version="1.0.1",
version="1.0.2",
author="LambdaTest <keys@lambdatest.com>",
description="Python Selenium SDK for testing with Smart UI",
long_description=long_description,
Expand Down
8 changes: 5 additions & 3 deletions utils/lambdatest_sdk_utils/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ def fetch_dom_serializer():
raise Exception(f'fetch DOMSerializer failed')


def post_snapshot(dom,snaphshotname,pkg):
def post_snapshot(snapshot,pkg,**kwargs):
try:
response = requests.post(f'{SMART_UI_API}/snapshot', json={
'snapshot': {
'dom' : dom['dom']['html'],
'name' : snaphshotname
'dom' : snapshot['dom'],
'name' : snapshot['name'],
'url' : snapshot['url'],
**kwargs
},
'testType': pkg
})
Expand Down
2 changes: 1 addition & 1 deletion utils/lambdatest_sdk_utils/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.0.0'
__version__ = '1.0.1'
2 changes: 1 addition & 1 deletion utils/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name="lambdatest-sdk-utils",
version="1.0.0",
version="1.0.1",
author="LambdaTest <keys@lambdatest.com>",
description="SDK utils",
long_description="SDK utils for lambdatest",
Expand Down