Skip to content

Releases: seleniumbase/SeleniumBase

Allow parallel tests with "-n=NUM" when using "--dashboard" mode, and more.

16 Apr 07:08
24e18ab
Compare
Choose a tag to compare

Allow parallel tests with -n=NUM when using --dashboard mode, and more.

  • Add the ability to run parallel tests when using the Dashboard.
    -- (Combine -n=NUM_PROCESSES with --dashboard)
  • Change thread-locking of the proxy zip file to process-locking.
  • Fix an issue with log files displaying the last browser used.
  • Update the check_window() method for visual layout tests.
  • Update JS dependencies.
  • Update Python dependencies:
    -- filelock==3.0.12
    -- fasteners==0.16

This resolves:

New methods and lots of optimizations

10 Apr 17:54
83faa23
Compare
Choose a tag to compare

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:

Update Firefox settings on Linux and update dependencies

06 Apr 02:59
f781e98
Compare
Choose a tag to compare

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"

Update error-handling and dependencies

03 Apr 03:00
907b1ed
Compare
Choose a tag to compare

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"

Refactor methods and other updates

29 Mar 04:05
ab94569
Compare
Choose a tag to compare

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"

Lots of refactoring and efficiency improvements

26 Mar 22:12
8173611
Compare
Choose a tag to compare

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"

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

23 Mar 22:08
8a96e11
Compare
Choose a tag to compare

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!)

Add the ability to set custom Chromium args. And more.

23 Mar 19:59
bf807a7
Compare
Choose a tag to compare

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.
    -- 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).

Add support for Shadow DOM interaction and more

23 Mar 07:04
5f69a8e
Compare
Choose a tag to compare

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"

Update console scripts and file-download functionality

19 Mar 04:36
76f0c4e
Compare
Choose a tag to compare

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