Skip to content

@mdmintz mdmintz released this Apr 10, 2021

New methods and lots of optimizations

New methods:

  • self.switch_to_newest_window()
  • self.assert_elements_present(*args, **kwargs)
  • self.assert_elements(*args, **kwargs)
    -- Duplicates: self.assert_elements_visible(*args, **kwargs)

The self.switch_to_newest_window() is very useful because sometimes tests open up a new tab/window, and you need to be able to switch to the newest one easily.

The new assert methods are very useful because now you can assert multiple elements in a single assert statement. (Note the difference between "present" and "visible", as "present" allows for both hidden and visible elements.) The input can either be a list of css selectors, or individual args. Example:

from seleniumbase import BaseCase

class MyTestClass(BaseCase):

    def test_assert_list_of_elements(self):
        self.open("https://store.xkcd.com/collections/posters")
        self.assert_elements_present("head", "style", "script")
        self.assert_elements("h1", "h2", "h3")
        my_list = ["#top-menu", "#col-main", "#col-widgets"]
        self.assert_elements(my_list)

Other changes include:

  • Allow the use of conftest.py for configuring pytest.
  • Bypass data: URLs when doing link-checking for 404s.
  • Optimize JavaScript calls that require the use of jQuery.
  • Optimize Dashboard output and favicon display.
  • Update the default version of Geckodriver installed.
  • Optimize logging output.
  • Optimize some existing methods.
  • Update Python dependencies:
    -- setuptools>=56.0.0;python_version>="3.6"

Full list of additions, changes, and fixes:

Assets 2

@mdmintz mdmintz released this Apr 6, 2021 · 23 commits to master since this release

Update Firefox settings on Linux and update dependencies

  • Update Firefox settings on Linux for better compatibility
  • Also update Python dependencies:
    -- pytest==6.2.3;python_version>="3.6"
    -- rich==10.1.0;python_version>="3.6"
Assets 2

@mdmintz mdmintz released this Apr 3, 2021 · 28 commits to master since this release

Update error-handling and dependencies

  • Update error-handling for save_teardown_screenshot()
  • Update Python dependencies:
    -- parso==0.8.2;python_version>="3.6"
    -- decorator==4.4.2
    -- Pillow==8.2.0;python_version>="3.6"
    -- rich==10.0.1;python_version>="3.6"
Assets 2

@mdmintz mdmintz released this Mar 29, 2021 · 36 commits to master since this release

Refactor methods and other updates

  • Refactor BaseCase methods to reduce code:
    -- Duplicate code was pulled into one method.
  • Update JS methods that type backspaces:
    -- Use Keys.BACK_SPACE instead of "\b"
  • Optimize wait_for_ready_state_complete():
    -- Shorten timeout and don't raise exceptions.
    -- ("interactive" state is often good enough)
  • Refactor imports for exception-handling:
    -- Import from: "selenium.common.exceptions"
    -- Previously, exceptions were imported from:
    -- "selenium.webdriver.remote.errorhandler"
    -- (Now the exception imports are consistent.)
  • Update Python dependencies:
    -- ipython==7.22.0;python_version>="3.7"
    -- rich==10.0.0;python_version>="3.6"
Assets 2

@mdmintz mdmintz released this Mar 26, 2021 · 45 commits to master since this release

Lots of refactoring and efficiency improvements

  • Refactor browser_launcher.py.
    -- (Get ready for deprecations coming in selenium 4.)
  • Have assert_text_not_visible() return True if successful.
    -- (It still fails the test if the unexpected text is still visible.)
  • Refactor seleniumbase resource files:
    -- Save space by moving copies of resource files out of the repo.
    -- (Most JS files were already getting retrieved via CDN link.)
  • Refactor seleniumbase imports.
    -- (Defer importing packages until needed, which saves time.)
  • Update non-required dependencies:
    -- pyflakes==2.3.1;python_version>="3.5"
Assets 2

@mdmintz mdmintz released this Mar 23, 2021 · 57 commits to master since this release

Improve reliability of the HTML-Inspector and JS-loading code

from seleniumbase import BaseCase

class HtmlInspectorTests(BaseCase):
    def test_html_inspector(self):
        self.open("https://xkcd.com/1144/")
        self.inspect_html()

pytest test_inspect_html.py 
============================ test session starts ============================
platform darwin -- Python 3.9.2, pytest-6.2.2, py-1.10.0, pluggy-0.13.1
rootdir: /Users/michael/github/SeleniumBase/examples, configfile: pytest.ini
plugins: html-2.0.1, rerunfailures-9.1.1, xdist-2.2.1, metadata-1.11.0,
         ordering-0.6, forked-1.3.0, seleniumbase-1.59.2
collected 1 item                                                                                                        

test_inspect_html.py 
* HTML Inspection Results: https://xkcd.com/1144/
X - https://xkcd.com/1144/ - Access to XMLHttpRequest at 'https://xkcd.com/usBanner' (redirected from 'https://c.xkcd.com/xkcd/news') from origin 'https://xkcd.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
X - https://xkcd.com/usBanner - Failed to load resource: net::ERR_FAILED
X - 'property' is not a valid attribute of the <meta> element.
X - Do not use <div> or <span> elements without any attributes.
X - The 'alt' attribute is required for <img> elements.
X - The 'border' attribute is no longer valid on the <img> element and should not be used.
X - 'srcset' is not a valid attribute of the <img> element.
X - The <center> element is obsolete and should not be used.
X - <script> elements should appear right before the closing </body> tag for optimal performance.
X - The id 'comicLinks' appears more than once in the document.
* (See the Console output for details!)
Assets 2

@mdmintz mdmintz released this Mar 23, 2021 · 60 commits to master since this release

Add the ability to set custom Chromium args. And update downloads.

  • Add custom Chromium args with: --chromium-arg="ARG,ARG".
    -- (As demonstrated, this can be a comma-separated list)
    -- If there's already a specific command-line option for the custom argument that you want to include, you should use the built-in option instead in order to maximize SeleniumBase compatibility. (See help_docs/customizing_test_runs.md and seleniumbase/plugins/pytest_plugin.py for examples of command-line args.) You can also type: sbase options on the command-line for a list of the most popular command-line options to use with SeleniumBase.

  • Have get_downloads_folder() return the ./downloaded_files/ path.
    -- (This only changes the outcome when using Chromium Guest Mode.)
    -- Note: SeleniumBase has always set the custom downloads folder to be ./downloaded_files/ from the location where tests are launched, however, Chromium Guest Mode (non-headless) does not allow the changing of the default system downloads folder, which is where files go when a browser click initiates a file download. This can be an issue if using BOTH Guest Mode AND clicking to download files, because then those files won't be in SeleniumBase's isolated environment. The good news is that download_file(file_url) will still always use the custom ./downloaded_files/ folder because only browser click-initiated downloads are impacted (and only for headed Guest Mode, IE, and Safari tests). So get_downloads_folder() will point to the SeleniumBase custom path one, and get_browser_downloads_folder() will point to the location where click-initiated browser downloads go. For most browsers (non-guest Chrome, Edge, Firefox) those methods will return the same location (./downloaded_files/). However, Guest Mode Chrome, Safari, and IE (where the system downloads folder can't be changed) will have two download locations, based on how your test downloads the file. (See examples/test_download_files.py and examples/test_shadow_dom.py for example tests that download files.)
    When calling a method such as assert_downloaded_file(file), it will check the ./downloaded_files/ location by default, but there is a keyword option that you can add (browser=True) so that it looks in the system/browser-click-initiated downloads folder instead (which may be the same location): assert_downloaded_file(file, browser=True).

Assets 2

@mdmintz mdmintz released this Mar 23, 2021 · 68 commits to master since this release

Add support for Shadow DOM interaction and more

  • Add support for interacting with Shadow DOM elements
    -- (By adding the ::shadow piercing selector)
    -- (See the example test: examples/test_shadow_dom.py)
  • Improve Website-TourMaker reliability
    -- (Website Tours will run more smoothly)
  • Update console scripts for test generation
    -- (For the sbase mkdir DIR command)
  • Make the execute_script() methods more flexible
    -- (Additional parameters can be passed into the script)
  • Update Python dependencies:
    -- setuptools>=54.2.0;python_version>="3.6"
    -- soupsieve==2.2.1;python_version>="3.6"
    -- prompt-toolkit==3.0.18;python_version>="3.6"
Assets 2

@mdmintz mdmintz released this Mar 19, 2021 · 83 commits to master since this release

Update console scripts and file-download functionality

  • Update console scripts (Add more files with sbase mkdir DIR)
  • Empty the ./downloaded_files/ folder when a new run begins
    -- (Previously, this happened each time a new browser was launched)
  • Add a new method: self.delete_downloaded_file_if_present(file)
  • Update the list of SeleniumBase Syntax Formats
    -- (No code changes, but this is a really useful list!)
    -- SeleniumBase/help_docs/syntax_formats.md
  • Update several example tests
Assets 2

@mdmintz mdmintz released this Mar 18, 2021 · 91 commits to master since this release

Reliability and other improvements

  • Improve Demo Mode reliability on sites with restrictive CSPs.
  • Improve Safari reliability on the self.open_new_window() method.
  • Update default driver versions used and displayed:
    -- Use Edgedriver "89.0.774.54" if cannot detect LATEST_STABLE
    -- Use Operadriver "v.88.0.4324.104" as the default version
  • Improve self.assert_downloaded_file(file).
  • When reusing a session, only keep the first tab/window open.
  • Update Python dependencies:
    -- setuptools-scm==5.0.2;python_version<"3.6"
    -- setuptools-scm>=6.0.1;python_version>="3.6"
    -- Drop allure-pytest from installed dependencies
Assets 2