From f83a4e2b6f582140a176dfe6b0d1f4e289db7897 Mon Sep 17 00:00:00 2001 From: shreyanshc Date: Tue, 1 Jul 2025 13:59:10 +0530 Subject: [PATCH] Added smartui sample --- features/environment.py | 4 ++++ features/steps/steps.py | 6 +++++- features/test.feature | 8 +++++++- requirements.txt | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/features/environment.py b/features/environment.py index 81552e5..22bb37d 100644 --- a/features/environment.py +++ b/features/environment.py @@ -36,6 +36,10 @@ def before_scenario(context, scenario): options = EdgeOptions() options.browser_version = desired_cap.get("version", "latest") options.platform_name = "Windows 8" + elif 'SmartUI' in scenario.tags: + options = ChromeOptions() + options.browser_version = desired_cap.get("version", "latest") + options.set_capability('smartUI.project','Python-Behave-sample') else: raise ValueError("Unsupported browser tag") diff --git a/features/steps/steps.py b/features/steps/steps.py index 3ede1d6..3cbf40f 100644 --- a/features/steps/steps.py +++ b/features/steps/steps.py @@ -40,4 +40,8 @@ def step(context, text): @then('click the "{button}"') def step(context, button): element = wait_for_element(context, By.ID, button) - element.click() \ No newline at end of file + element.click() + +@then('take smartui snapshot') +def step(context): + context.browser.execute_script("smartui.takeScreenshot= to-do") \ No newline at end of file diff --git a/features/test.feature b/features/test.feature index c6a475c..c4deac4 100644 --- a/features/test.feature +++ b/features/test.feature @@ -25,4 +25,10 @@ Feature: Automate a website When field with name "First Item" is present check the box When field with name "Second Item" is present check the box When select the textbox add "Let's add new to do item for Edge" in the box - Then click the "addbutton" \ No newline at end of file + Then click the "addbutton" + + @SmartUI + Scenario: Capture smartui snapshot + When visit url "https://lambdatest.github.io/sample-todo-app" + When check if title is "Sample page - lambdatest.com" + Then take smartui snapshot \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 61e3cf2..3205a40 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ Paver==1.3.4 selenium>4.23.0 behave==1.2.6 -behavex==1.6.0 \ No newline at end of file +behavex>1.6.0 \ No newline at end of file