github seleniumbase/SeleniumBase v2.1.1
Updates to Recorder Mode and Multi-Factor Auth methods

latest releases: v4.32.9, v4.32.8, v4.32.7...
3 years ago

Updates to Recorder Mode and Multi-Factor Auth methods

  • Add self.save_recorded_actions()
"""(When using Recorder Mode, use this method if you plan on
navigating to a different domain/origin in the same tab.)
This method saves recorded actions from the active tab so that
a complete recording can be exported as a SeleniumBase file at the
end of the test. This is only needed in special cases because most
actions that result in a new origin, (such as clicking on a link),
should automatically open a new tab while Recorder Mode is enabled."""
  • Add self.enter_mfa_code(selector, totp_key):
"""Enters into the field a Multi-Factor Authentication TOTP Code.
If the "totp_key" is not specified, this method defaults
to using the one provided in [seleniumbase/config/settings.py].
The TOTP code is generated by the Google Authenticator Algorithm.
This method will automatically press ENTER after typing the code."""
  • Improve Recorder Mode event-processing.

  • Refactor MFA methods:

self.get_mfa_code(totp_key=None)
# Duplicates: self.get_totp_code(totp_key=None)
#             self.get_google_auth_password(totp_key=None)
#             self.get_google_auth_code(totp_key=None)

self.enter_mfa_code(selector, totp_key=None, by=By.CSS_SELECTOR, timeout=None)
# Duplicates: self.enter_totp_code(selector, totp_key=None, by=By.CSS_SELECTOR, timeout=None)
  • Refresh Python dependencies:
    -- setuptools>=58.4.0;python_version>="3.6"
    -- virtualenv>=20.10.0

Here's a longer description of why self.save_recorded_actions() might be needed in some special cases:

🔴 Recorder Mode works by saving your recorded actions into the browser's sessionStorage. SeleniumBase then reads from the browser's sessionStorage to take the raw data and generate a full test from it. Keep in mind that sessionStorage is only present for a website while the browser tab remains on a web page of the same domain/origin. If you leave that domain/origin, the sessionStorage of that tab will no longer have the raw data that SeleniumBase needs to create a full recording. To compensate for this, all links to web pages of a different domain/origin will automatically open a new tab for you while in Recorder Mode. Additionally, the SeleniumBase self.open(URL) method will also open a new tab for you in Recorder Mode if the domain/origin is different from the current URL. If you need to navigate to a different domain/origin from within the same tab, call self.save_recorded_actions() first, which saves the recorded data for later. When the recorded test completes, SeleniumBase will scan the sessionStorage of all open browser tabs for the data it needs to generate the complete SeleniumBase automation script.

Don't miss a new SeleniumBase release

NewReleases is sending notifications on new releases.