Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Michael Mintz
    @mdmintz
    I found this: https://stackoverflow.com/questions/63944480/maxretryerror-selenium (but that shouldn't be happening when using SeleniumBase)
    RusKFA
    @RusKFA
    Meh, im using Selenium to parse something from site twice
    but here an error
    idk why
    Michael Mintz
    @mdmintz
    @RusKFA I need to see the stack trace and the SeleniumBase method you called in order to help.
    Michael Mintz
    @mdmintz
    Also, Support for Python 3.5 is expected to be dropped in SeleniumBase 3.5.0 - Expecting zero impact because there have been no Python 3.5 downloads in the past week.
    Michael Mintz
    @mdmintz
    https://github.com/seleniumbase/SeleniumBase/releases/tag/v3.5.2 is out. Reduces required Python dependencies. Leads to faster installs on CI/CD.
    grezald
    @grezald
    Hey @mdmintz. 1) after updating SB recently, our team noticed a huge reduction in runtime. Thank you! Its been about 3-5 weeks since I last updated. Do you have any idea what most likely would have caused most of this improvement?
    grezald
    @grezald
    2) As long as we’ve used SB, we’ve experienced situations where an element is clicked but the page doesn’t register the click and thus fails the following function call. For example, clicking a next page button and then asserting the title of the next page results in a failed assertion since the element never registered the click. Since this is in the middle of a much larger test, I’d rather it not rerun the entire test, and only try to click the “next” button again (assuming that it didnt register). To be clear, I think SB is working correctly in these scenarios (since running in slow mode solves the issue). I know that you have conditions built into clicking to ensure elements have been clicked, but sometimes, I think SB finds and clicks buttons (too quickly 😅👍) before the page can even register clicks. Is there a way to have a faster “slow” mode or would you consider building in a feature to try the previous function if the current fails, rather than only the option of a full test rerun on failures?
    Michael Mintz
    @mdmintz
    Hi @grezald For number 1, SeleniumBase had a reduction in optional dependencies that were installed during pip install, so if your tests always install dependencies before running tests, you'll see a big improvement: See seleniumbase/SeleniumBase#1406 (a significant savings)
    For 2, you can control how slow is slow_mode. Use:
    --demo_sleep=SEC (It uses the demo_mode timeout for slow_mode)
    Michael Mintz
    @mdmintz
    The default value for that is 0.5 seconds.
    grezald
    @grezald
    We have our dependencies installed locally, so I don’t think those upgrades are related. Our tests are running 400% faster, so it’s something. Ill try the demo command. Ty!
    Michael Mintz
    @mdmintz
    @grezald OK, great! Perhaps the performance boost was due to one of many different optimizations that took place. Could be anything from changes in default Chromium/Firefox command-line options, or even improvements made in the latest version of selenium. But whatever it was, looks like it was a great improvement!
    joachimb
    @joachimb:matrix.org
    [m]
    how can I use the window size command line option?
    pytest test_regression.py --alluredir=report --window-size=1920,1080
    this is not working
    Michael Mintz
    @mdmintz
    @joachimb:matrix.org What are you seeing? When I run pytest my_first_test.py --window-size=600,600 I correctly see the browser window at the correct size.
    1 reply
    sarchule
    @sarchule
    Using sbase 3.5.8 with behave: I'm trying to use behave's before_all() functionality (https://behave.readthedocs.io/en/stable/api.html?highlight=before_all#environment-file-functions). If I define this function within the environment.py module (to just print some text to stdout), it successfully prints the line, but then throws a "HOOK-ERROR in before_scenario: AttributeError: 'Context' object has no attribute 'sb'". Note that the error is about "before_scenario" despite the fact that I'm only defining "before_all". I am using same environment.py module as located in seleniumbase behave examples (aside from newly defined "before_all(context)"). Is it possible to use these behave functions (before_all, before_feature, before_scenario, etc.)?
    Michael Mintz
    @mdmintz
    @sarchule SeleniumBase already overrode the default behave methods like before_all, before_feature, before_scenario, etc, at the end of this file: https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/behave/behave_sb.py
    If overriding them again, you would need to preserve the existing SeleniumBase versions of those methods.
    9 replies
    Evgenii
    @EvgeniiBiriukov
    Michael, hello! SeleniumBase is cool! For example, I want to display not only standard data in an html report. What if I want to display the value of some variable from my code in the report. Is it even possible?
    I understand that it is possible to output the values of variables in the description of the error that Pytest made.
    But, how to display the value of the variable in the html-report itself, and not in the error description?
    Michael Mintz
    @mdmintz
    Hi @EvgeniiBiriukov The pytest-html report is a separate plugin with a separate maintainer. There may be a few possible workarounds, such as using print() commands to output the data as the test runs.
    You can also use self.save_data_as(data, file_name, destination_folder=None) to save that data to a file.
    Evgenii
    @EvgeniiBiriukov
    Michael, thanks!
    Michael Mintz
    @mdmintz
    Michael Mintz
    @mdmintz
    (More like live demos than a presentation. No slides.)
    sarchule
    @sarchule
    When using SeleniumBase "sb" pytest fixture syntax, does anyone know how to set up Visual Studio Code to allow intellisense and "go to definition" features? I've tried various extensions (e.g., python, pytest-fixtures, etc.) without success. I know this isn't a specific SeleniumBase issue, but hoping someone has figured out the magic to making this happen.
    Michael Mintz
    @mdmintz
    @sarchule that's a generic Visual Studio Code issue with pytest fixtures. It doesn't autodetect the available methods.
    1 reply
    Mehmet Burak Sayıcı
    @mburaksayici
    Ekran Resmi 2022-08-08 21.06.14.png

    Hi @mdmintz ,
    We want to access button element that contains text in its child span, having issues due to there s no id that we can access to that button. Is there any way?

    We can actually get the span, but can not access to the parent button and cant click on it, snippet attached

    Michael Mintz
    @mdmintz
    Michael Mintz
    @mdmintz
    Always use it with a tag. So: tag:contains("TEXT") Eg: button:contains("TEXT").
    Mehmet Burak Sayıcı
    @mburaksayici

    it worked in chrome, it was failing for safari, thanks..

    Also, what if i have dynamic class name, class="styles_SelectFiltersBW-i1" , that BW-i1 is created by react, how can i access that class through SelectFilters?

    Ekran Resmi 2022-08-09 00.47.14.png
    Michael Mintz
    @mdmintz
    @mburaksayici You can use [class*="PARTIAL_CLASS"] for matching on a partial class name.
    Deniz
    @denizdugru
    Hi @mdmintz , I have been working with your framework for almost 2 months, I appricate the hard work and good communication of yours. I wonder if seleniumbase is capable of handling API responses, as far as I know its doable to reach http responses through selenium's webdrivers.
    Evgenii
    @EvgeniiBiriukov
    Michael, hello! SeleniumBase as always on top! Is it possible to change the zoom level of the browser to perform the autotest?
    Michael Mintz
    @mdmintz
    @denizdugru Yes, it can, through https://github.com/wkeeling/selenium-wire (installed separately):
    from seleniumbase import BaseCase
    from seleniumwire import webdriver  # the selenium-wire webdriver
    
    class WireTestCase(BaseCase):
        def get_new_driver(self, *args, **kwargs):
            options = webdriver.ChromeOptions()
            options.add_experimental_option("excludeSwitches", ["enable-automation"])
            options.add_experimental_option("useAutomationExtension", False)
            return webdriver.Chrome(options=options)
    
        def test_simple(self):
            self.open("https://seleniumbase.io/demo_page")
            for request in self.driver.requests:
                print(request.url)
    @EvgeniiBiriukov See if https://stackoverflow.com/a/31482681/7058266 works for you.
    Evgenii
    @EvgeniiBiriukov

    @EvgeniiBiriukov See if https://stackoverflow.com/a/31482681/7058266 works for you.

    Michael, thanks! It works correctly.

    Deniz
    @denizdugru
    Thank you @mdmintz
    taylorm
    @taylorm:matrix.org
    [m]

    Hi there! I don't know if I've said enough previously but thank you so much for your help working through things. Can you help me figure out capabilities changes with selenium 4? I use Gridlastic (selenium grid cloud provider) and with selenium 4, they are looking for this to enable video recording:

    {
            "gridlastic:options":
            {
                "video": true,
            }
    }

    I tried adding a caps.json file to test setting that, and it got added as this (cut out some lines for brevity):

    {
        "cloud:options":
        {
            "gridlastic:options":
            {
                "video": true,
            }
        }
    }

    Is there a way to currently pass in capabilities that don't get put under cloud:options? Or can you add functionality that checks the caps provided to SB, and if it is in the format of {string}:{string} pass them straight through without putting it under cloud:options?
    See the note "(check with your cloud vendor for the appropriate prefix)" on this page: https://www.selenium.dev/documentation/webdriver/getting\_started/upgrade\_to\_selenium\_4/#capabilities

    Michael Mintz
    @mdmintz
    @taylorm:matrix.org You'd probably use something similar to a SeleniumBase cap file: https://github.com/seleniumbase/SeleniumBase/blob/master/examples/capabilities/selenoid_cap_file.py
    And then pass in the file with --cap_file=CAP_FILE.py
    taylorm
    @taylorm:matrix.org
    [m]

    I tried with a similar cap file as suggested, but actually, if I understand these lines correctly, then seleniumbase will nest all capabilities provided under cloud:options except for the ones handled specifically here (selenoid:options, screenResolution, version, platform). These handled ones get put at the top level, instead of under cloud:options. I was poking at browser_launcher on how it could be handled differently and came up with this (L1, L13-14, L29-31 here):

            custom_options = {}
            for key in desired_caps.keys():
                capabilities[key] = desired_caps[key]
                if key == "selenoid:options":
                    selenoid = True
                    selenoid_options = desired_caps[key]
                elif key == "screenResolution":
                    screen_resolution = desired_caps[key]
                elif key == "version" or key == "browserVersion":
                    browser_version = desired_caps[key]
                elif key == "platform" or key == "platformName":
                    platform_name = desired_caps[key]
                elif re.match("[a-zA-Z0-9]*:[a-zA-Z0-9]*", key):
                    custom_options[key] = desired_caps[key]
            if selenium4:
                chrome_options.set_capability("cloud:options", capabilities)
                if selenoid:
                    snops = selenoid_options
                    chrome_options.set_capability("selenoid:options", snops)
                if screen_resolution:
                    scres = screen_resolution
                    chrome_options.set_capability("screenResolution", scres)
                if browser_version:
                    br_vers = browser_version
                    chrome_options.set_capability("browserVersion", br_vers)
                if platform_name:
                    plat_name = platform_name
                    chrome_options.set_capability("platformName", plat_name)
                if custom_options:
                    for key in custom_options:
                        chrome_options.set_capability(key, custom_options[key])

    open to your thoughts - this will handle multiple custom capabilities (meaning a cap that is string:string) should I submit a PR?

    Michael Mintz
    @mdmintz
    @taylorm:matrix.org Could work. Just make sure to test it on the latest Python, AND 3.6 for pre-selenium-4 compatibility. Then submit a PR. Be sure to run flake8. If everything's good, I'll make a release for this. I'm working on a few big things, such as seleniumbase/SeleniumBase#1440
    Michael Mintz
    @mdmintz
    I can probably test it out as I get close to the next release, and then I can add it in directly. Looks like it should work.