Skip to content

Releases: seleniumbase/SeleniumBase

3.0.1 - A few fixes (Dockerfile and "behave" Dashboard)

14 May 14:19
b0563d5
Compare
Choose a tag to compare

A few fixes (Dockerfile and behave Dashboard)

3.0.0 - SeleniumBase 3

13 May 22:34
88fa040
Compare
Choose a tag to compare

3.0.0 - SeleniumBase 3


🐝 Behave test runner for SeleniumBase 🐝

🐝 (Utilizes the Behave BDD Python library. For more info, see the Behave tutorial and read about Behave's Gherkin model.)

🐝 Behave examples with SeleniumBase: SeleniumBase/examples/behave_bdd

> cd examples/behave_bdd/
> behave features/realworld.feature -T -D dashboard -k

Dashboard: /Users/michael/github/SeleniumBase/examples/behave_bdd/dashboard.html
********************************************************************************
Feature: SeleniumBase scenarios for the RealWorld App # features/realworld.feature:1

  Scenario: Verify RealWorld App (log in / sign out)  # features/realworld.feature:3
    Given Open "seleniumbase.io/realworld/login"      # ../../sbase/steps.py:4
    And Clear Session Storage                         # ../../sbase/steps.py:374
    When Type "demo_user" into "#username"            # ../../sbase/steps.py:22
    And Type "secret_pass" into "#password"           # ../../sbase/steps.py:22
    And Do MFA "GAXG2MTEOR3DMMDG" into "#totpcode"    # ../../sbase/steps.py:179
    Then Assert exact text "Welcome!" in "h1"         # ../../sbase/steps.py:75
    And Highlight "img#image1"                        # ../../sbase/steps.py:82
    And Click 'a:contains("This Page")'               # ../../sbase/steps.py:13
    And Save screenshot to logs                       # ../../sbase/steps.py:107
    When Click link "Sign out"                        # ../../sbase/steps.py:91
    Then Assert element 'a:contains("Sign in")'       # ../../sbase/steps.py:52
    And Assert text "You have been signed out!"       # ../../sbase/steps.py:68
   ✅ Scenario Passed!

- Dashboard: /Users/michael/github/SeleniumBase/examples/behave_bdd/dashboard.html
==================================================================================
1 feature passed, 0 failed, 0 skipped
1 scenario passed, 0 failed, 0 skipped
12 steps passed, 0 failed, 0 skipped, 0 undefined
Took 0m4.682s

🐝 Another example, which uses higher-level Behave steps to simplify the .feature file:

> cd examples/behave_bdd/
> behave features/calculator.feature:61 -T -D dashboard -k

Dashboard: /Users/michael/github/SeleniumBase/examples/behave_bdd/dashboard.html
********************************************************************************
Feature: SeleniumBase scenarios for the Calculator App # features/calculator.feature:1

  Background:   # features/calculator.feature:3

  Scenario: 7.0 × (3 + 3) = 42        # features/calculator.feature:49
    Given Open the Calculator App     # features/steps/calculator.py:4
    When Press C                      # features/steps/calculator.py:9
    And Press 7                       # features/steps/calculator.py:79
    And Press .                       # features/steps/calculator.py:104
    And Press 0                       # features/steps/calculator.py:94
    And Press ×                       # features/steps/calculator.py:29
    And Press (                       # features/steps/calculator.py:14
    And Press 3                       # features/steps/calculator.py:59
    And Press +                       # features/steps/calculator.py:39
    And Press 3                       # features/steps/calculator.py:59
    And Press )                       # features/steps/calculator.py:19
    Then Verify output is "7.0×(3+3)" # features/steps/calculator.py:135
    When Press =                      # features/steps/calculator.py:44
    Then Verify output is "42"        # features/steps/calculator.py:135
   ✅ Scenario Passed!

- Dashboard: /Users/michael/github/SeleniumBase/examples/behave_bdd/dashboard.html
==================================================================================
1 feature passed, 0 failed, 0 skipped
1 scenario passed, 0 failed, 8 skipped
14 steps passed, 0 failed, 60 skipped, 0 undefined
Took 0m1.672s

🔵🐝⚪ With the Dashboard enabled, you'll get one of these:

🐝 Understanding Behave files:

🐝 The *.feature files can use any step seen from:

behave --steps-catalog

🐝 SeleniumBase includes several pre-made Behave steps, which you can use by creating a Python file with the following line in your features/steps/ directory:

from seleniumbase.behave import steps  # noqa

🐝 Inside your features/environment.py file, you should have the following:

from seleniumbase import BaseCase
from seleniumbase.behave import behave_sb
behave_sb.set_base_class(BaseCase)  # Accepts a BaseCase subclass
from seleniumbase.behave.behave_sb import before_all  # noqa
from seleniumbase.behave.behave_sb import before_feature  # noqa
from seleniumbase.behave.behave_sb import before_scenario  # noqa
from seleniumbase.behave.behave_sb import before_step  # noqa
from seleniumbase.behave.behave_sb import after_step  # noqa
from seleniumbase.behave.behave_sb import after_scenario  # noqa
from seleniumbase.behave.behave_sb import after_feature  # noqa
from seleniumbase.behave.behave_sb import after_all  # noqa

🐝 If you've already created a subclass of BaseCase with custom methods, you can swap BaseCase in with your own subclass, which will allow you to easily use your own custom methods in your Behave step definitions.

🐝 Here's an example Python file in the features/steps/ folder:

from behave import step


@step("Open the Swag Labs Login Page")
def go_to_swag_labs(context):
    sb = context.sb
    sb.open("https://www.saucedemo.com")
    sb.clear_local_storage()


@step("Login to Swag Labs with {user}")
def login_to_swag_labs(context, user):
    sb = context.sb
    sb.type("#user-name", user)
    sb.type("#password", "secret_sauce\n")


@step("Verify that the current user is logged in")
def verify_logged_in(context):
    sb = context.sb
    sb.assert_element("#header_container")
    sb.assert_element("#react-burger-menu-btn")
    sb.assert_element("#shopping_cart_container")


@step('Add "{item}" to cart')
def add_item_to_cart(context, item):
    sb = context.sb
    sb.click('div.inventory_item:contains("%s") button[name*="add"]' % item)

🐝 A *.feature file could look like this:

Feature: SeleniumBase scenarios for the Swag Labs App

    Background:
        Given Open the Swag Labs Login Page

    Scenario: User can order a backpack from the store
        When Login to Swag Labs with standard_user
        Then Verify that the current user is logged in
        And Save price of "Backpack" to <item_price>
        When Add "Backpack" to Cart
        Then Verify shopping cart badge shows 1 item(s)
        When Click on shopping cart icon
        And Click Checkout
        And Enter checkout info: First, Last, 12345
        And Click Continue
        Then Verify 1 "Backpack"(s) in cart
        And Verify cost of "Backpack" is <item_price>
        And Verify item total is $29.99
        And Verify tax amount is $2.40
        And Verify total cost is $32.39
        When Click Finish
        Then Verify order complete
        When Logout from Swag Labs
        Then Verify on Login page

🐝 Here's another example of a *.feature file:

Feature: SeleniumBase scenarios for the RealWorld App

    Scenario: Verify RealWorld App (log in / sign out)
        Given Open "seleniumbase.io/realworld/login"
        And Clear Session Storage
        When Type "demo_user" into "#username"
        And Type "secret_pass" into "#password"
        And Do MFA "GAXG2MTEOR3DMMDG" into "#totpcode"
        Then Assert text "Welcome!" in "h1"
        And Highlight element "img#image1"
        And Click 'a:contains("This Page")'
        And Save screenshot to logs
        When Click link "Sign out"
        Then Assert element 'a:contains("Sign in")'
        And Assert text "You have been signed out!"

🐝 If there's a test failure, that's easy to spot:

Feature: SeleniumBase scenarios for the Fail Page # features/fail_page.feature:1

  Scenario: Fail test on purpose to see what happens  # features/fail_page.feature:3
    When Open the Fail Page                           # features/steps/fail_page.py:4
    Then Fail test on purpose                         # features/steps/fail_page.py:9
      Assertion Failed: This test fails on purpose!
  ...
Read more

2.5.4.post1 - Post release to fix an issue with PyPI installs

02 May 23:22
Compare
Choose a tag to compare

Post release to fix an issue with PyPI installs

Shipping a post release to fix #1293

2.5.4 - Fix Recorder bugs and improve deferred asserts

02 May 19:33
63c23cb
Compare
Choose a tag to compare

Fix Recorder bugs and improve deferred asserts

2.5.3 - Bug fixes and refreshing dependencies

01 May 14:38
2280327
Compare
Choose a tag to compare

2.5.2 - Desktop app updates for the Commander and Recorder

25 Apr 22:04
271d5fb
Compare
Choose a tag to compare

2.5.1 - Refresh Python dependencies

25 Apr 04:05
22f6876
Compare
Choose a tag to compare

2.5.0 - New feature: SeleniumBase Commander / GUI for pytest

22 Apr 07:14
b385e3e
Compare
Choose a tag to compare

2.4.35 - Fix parsing of custom_settings files and refresh dependencies

19 Apr 21:43
7191a8c
Compare
Choose a tag to compare

2.4.34 - iframe methods and more

18 Apr 05:46
242eb4d
Compare
Choose a tag to compare

iframe methods and more

Here's the full list of iframe method now (some already existed):

self.switch_to_frame(frame, timeout=None)

self.switch_to_default_content()

self.switch_to_parent_frame()

self.set_content_to_frame(frame, timeout=None)

self.set_content_to_default(nested=False)
# Duplicates: self.set_content_to_default_content(nested=False)

self.set_content_to_parent()
# Duplicates: self.set_content_to_parent_frame()

For an example of these methods in action, see: https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_iframes.py

If locating an element by the :contains("TEXT") selector and the element is not found, then the output will display that selector in CSS Selector format (rather than in the messy XPath format that the selector was converted to prior to being used). Note that the :contains("TEXT") CSS Selector is only valid in SeleniumBase, as it converts that into a valid XPath Selector before using it in a regular Selenium command.
Eg: 'div:contains("Math")' in SeleniumBase CSS becomes "//div[contains(., 'Math')]" in XPath.