Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    naveenasri
    @naveenasri
    how can I run using seleniumbase
    Also I’m unable to run tests in IE browser
    Same tests I can run in chrome and in headless as well
    Michael Mintz
    @mdmintz
    Hi @naveenasri, Only Chrome, Firefox, and Edge support headless mode.
    ZenIvan
    @ZenIvan
    Hi @mdmintz I noticed that headless mode is not accepting download file scenarios, have you encountered this?
    Michael Mintz
    @mdmintz
    @ZenIvan pytest test_download_files.py --headless works for me on https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_download_files.py
    Maybe try upgrading to a newer version of SeleniumBase if you're using an older version.
    10 replies
    naveenasri
    @naveenasri
    Thanks @mdmintz
    AgentRG
    @AgentRG
    Hmm... does SeleniumBase have a builtin ability to print out console/javascript errors when a test fails?
    From the browser.
    Michael Mintz
    @mdmintz
    @AgentRG Try self.assert_no_js_errors() in your tests (for Chromium-based browsers such as Chrome and Edge). If there are JS errors, the test will fail and you'll see the errors in the logs.
    AgentRG
    @AgentRG
    Awesome, thanks. I'll take a look at it.
    AgentRG
    @AgentRG
    That's what I was looking for. Thank you again.
    1 reply
    naveenasri
    @naveenasri
    @mdmintz
    Can you pls tell how can we run tests by switcing the browsers between chrome and IE
    For example few urls support only IE but not in chrome
    However some urls in the same test suite work only in Chrome
    how can I run those tests by switching the browsers and run tests in parallel
    Will I be able to run tests similarly in Jenkins
    Michael Mintz
    @mdmintz
    @naveenasri Inside the test of the suite where you want to switch to a different driver from what you set it to with pytest, use self.get_new_driver(browser=BROWSER), example: self.get_new_driver(browser="firefox").
    You can also quit the original driver with self.driver.quit().
    naveenasri
    @naveenasri
    Thanks Michael. I will give a try
    mkksbdinc
    @mkksbdinc
    Hi Michael, new to SeleniumBase but not to automation or programming, but I'm having an issue with an alert that pops when not running my test, but when I do run my test it does not pop, hence is not recognized and my test fails. What to do?
    Here is the description of my alert element:
    mkksbdinc
    @mkksbdinc
    <son-messagebox _ngcontent-bya-c0="" _nghost-bya-c1="">
    <div _ngcontent-bya-c1="" aria-labelledby="mySmallModalLabel" class="modal fade bs-example-modal-sm in" id="messageboxModal" role="dialog" tabindex="-1" style="display: block;">
    <div _ngcontent-bya-c1="" class="modal-dialog modal-sm" role="document">
    <div _ngcontent-bya-c1="" class="modal-content">
    <div _ngcontent-bya-c1="" class="modal-header">
    <button _ngcontent-bya-c1="" aria-label="Close" class="close" type="button"><span _ngcontent-bya-c1="" aria-hidden="true">×</span></button>
    <h4 _ngcontent-bya-c1="" class="modal-title" id="myModalLabel">mySonitrol</h4></div>
    <div _ngcontent-bya-c1="" class="modal-body"> A single facility must be selected to perform this action. </div>
    <div _ngcontent-bya-c1="" class="modal-footer">
    <button _ngcontent-bya-c1="" type="button">OK</button>
    <!---->
    </div>
    </div>
    </div>
    </div>
    </son-messagebox>
    zahed
    @zahed3795
    @mdmintz Thanks for the awesome framework. I really like it.
    1 reply
    Michael Mintz
    @mdmintz
    @mkksbdinc Have you tried self.accept_alert() or self.dismiss_alert()? If you know an alert will pop up, use one of these to accept or dismiss it.
    mkksbdinc
    @mkksbdinc
    yes, I've tried both. I think the problem is that for some reason the alert isn't popping, it pops every time when running manually. They both result in this exception: Exception: Alert was not present after 6 seconds!
    But yet, this method passes, not sure where or what it's showing, as I don't see the alert box.
    self.show_elements(hp.LOCATE_MESSAGE_MODAL), where, hp.LOCATE_MESSAGE_MODAL = "//*[@id='messageboxModal']/div/div/div[2]"
    The alert has an informational message with an OK button.
    Michael Mintz
    @mdmintz
    @mkksbdinc It's probably related to seleniumbase/SeleniumBase#600
    In summary, if you're about to hit a page with a pop-up, you should use self.find_element(SELECTOR).click() instead of self.click(SELECTOR) for the action that takes you to the pop-up. This is because self.execute_script(JAVASCRIPT) automatically closes any pop-ups, (which is used in self.wait_for_ready_state_complete(), which is called after most SeleniumBase actions to make sure the page is done loading before interacting with elements, thus improving test reliability.
    Michael Mintz
    @mdmintz
    The workaround would not be needed if self.driver.execute_script(JAVASCRIPT) did not automatically close any pop-ups that were open. The good news is that the workaround exists.
    mkksbdinc
    @mkksbdinc
    Thanks, I'll try it.
    mkksbdinc
    @mkksbdinc
    Hi Michael, somehow my framework, pytest, etc. became corrupt. Once I re-installed Python (upgrading to 3.9.0) and latest chromedriver. I am now seeing the alert overlay and all elements are accessible without the workaround.
    But thank you for your help.
    Michael Mintz
    @mdmintz
    @mkksbdinc When installing a new version of Python, reinstall all previously-installed packages. There are different requirements for different packages based on the version of Python installed.
    Michael Mintz
    @mdmintz
    New tool for previewing websites on multiple devices: https://seleniumbase.io/devices/?url=github.com
    Michael Mintz
    @mdmintz
    That tool is trending on Hacker News: https://news.ycombinator.com/item?id=24855342#24856356
    SeleniumBase v1.50.0 - https://github.com/seleniumbase/SeleniumBase/releases/tag/v1.50.0 has been released.
    elder-potato
    @elder-potato
    Is there a way to get the highlight and assert confirmations from the —demo flag without also having the slower speed? I have a bunch of other people writing tests and some have lengthy preconditions, the demo mode takes a lot of time to set up for each one
    Michael Mintz
    @mdmintz
    @elder-potato Was there an issue running tests without demo mode enabled? The highlighting of elements is what slows down demo mode on purpose. There's also slow mode, which is like demo mode, but without the highlighting.
    elder-potato
    @elder-potato
    The tests work fine, it's just that there can be a minute or two of setup when run in demo mode that takes maybe 15-20 seconds at normal speed. We have a couple forms with a ton of fields that need to be set up to enable the preconditions for the later parts of the test. And it gets tricky because later steps might invalidate the preconditions so they can't easily be "resumed" by a second run start after the preconditions are set.
    Michael Mintz
    @mdmintz
    @elder-potato You can also start demo mode in the middle of a test when not using demo mode by calling:
    self.demo_mode = True
    Also, there is a useful cmd option --reuse-session which will make all the tests run through the same browser window without closing the window and opening a new one. Add --crumbs when using that to clear any cookies between tests; otherwise, if you're already logged into a website in one test, you'll still be logged in when the next test runs.
    elder-potato
    @elder-potato
    That's very good about demo mode switch. I'll have to check —reuse-session as I'm pretty sure it still closes the window between sessions and requires us to log in again.
    AgentRG
    @AgentRG

    Hmm... does SeleniumBase edit anything called suid? When trying to run the tests inside Selenoid, the session ends midway through the test with the following output from Chrome.

    2020-10-26T23:04:57.984420392Z [1603753497.984][INFO]: [266bb50ca1589e1a96e17c3cf53806f4] COMMAND Quit { 2020-10-26T23:04:57.984506525Z 2020-10-26T23:04:57.984515270Z } 2020-10-26T23:04:58.040384893Z [1026/230458.039896:ERROR:nacl_helper_linux.cc(308)] NaCl helper process running without a sandbox! 2020-10-26T23:04:58.040441360Z Most likely you need to configure your SUID sandbox correctly 2020-10-26T23:04:58.055761281Z [1026/230458.046939:ERROR:nacl_helper_linux.cc(308)] NaCl helper process running without a sandbox! 2020-10-26T23:04:58.055830692Z Most likely you need to configure your SUID sandbox correctly

    It seems like setting chrome arguments to disable suid sandbox stopped the random driver exit.

    Michael Mintz
    @mdmintz
    @AgentRG I see that from zalando/zalenium#861
    Looks like the fix you used in https://stackoverflow.com/a/60549015 did the trick.
    ClancyDamon
    @ClancyDamon_twitter
    Hey Michael! I'm trying to properly utilize the setup and teardown of SeleniumBase and I'm running into a complication. In most our simple tests, we utilize DDT to pass in JSON data into our tests, and work from there. However, we're facing a more complicated situation where something we're testing is based on different data. We have a test case written for setting up employers in our web application, for example. Now, we'd like to have a test case for handling our employees, and those can only be created after the employers are setup. So functionally, we'd like to extend our EmployeeTestCase from EmployerTestCase, which itself is an extension of BaseCase. Then, in the overridden setup for the EmployeeTestCase, we'd like to run our EmployerTestCase methods that setup the employers so that the Employees can be tested. We're hitting a snag with the data, however. As stated, @file_data from DDT is how we pass our information into our tests. And ideally, we'd like to do the same thing with setup. Is this possible? We can't see a way to pass our information into setup. I can create an issue in GIT and provide code if this question isn't clear. Thank you.
    Michael Mintz
    @mdmintz

    Hi @ClancyDamon_twitter , I'm trying to fully understand your situation. You can have custom setup steps around your subclasses where you can specifically set initializations. For example, you can run custom setup code after calling Python super in this example: https://github.com/seleniumbase/SeleniumBase/blob/master/examples/boilerplates/base_test_case.py
    The same will work for multiple subclasses. It's just Python at that point. If that's not enough, you can also pass data on the command-line when running your tests. Example:

    --data=DATA  # (Extra test data. Access with "self.data" in tests.)
    --var1=DATA  # (Extra test data. Access with "self.var1" in tests.)
    --var2=DATA  # (Extra test data. Access with "self.var2" in tests.)
    --var3=DATA  # (Extra test data. Access with "self.var3" in tests.)

    And since you're already using DDT, you probably have already seen the example with File I/O for getting data for tests: https://github.com/seleniumbase/SeleniumBase/blob/master/examples/boilerplates/file_parsing/parse_files.py