SeleniumBase: ImportError: cannot import name 'Driver' from partially initialized module 'seleniumbase'
Hi there, just discovered seleniumbase. trying out the first example of the last video:
from seleniumbase import Driver
driver = Driver (uc=True)
try:
driver.get("https://nowsecure.nl/#relax")
driver.sleep(4)
# DO MORE STUFF
finally:
driver.quit()
getting the error:
from seleniumbase import Driver
ImportError: cannot import name 'Driver' from partially initialized module 'seleniumbase' (most likely due to a circular import) (/home/bangbuild/Documents/dev/cucumber/seleniumbase.py)
what am I missing?! thanks
About this issue
- Original URL
- State: closed
- Created 4 months ago
- Comments: 33 (13 by maintainers)
Video recording info: https://github.com/seleniumbase/SeleniumBase/discussions/2370#discussioncomment-7877316
Man it’s amazing!!! (got it working with
sudo apt install python3.10-tk) Everything is so smooth!! That’s it the test path is perfect 👍 Now I need to find how to record this window session to share it… Michael I can’t thank you enough for this amazing piece of software, truly magic ! 🙏 Have a great weekend my friend 😃js_click(selector)lets you click on “hidden” elements. From your error message, it saidElementNotVisibleException, which is different fromNoSuchElementException.That’s PERFEEECT! So cool, thanks a lot! Still struggling with the behave files but will share with you when I’m stuck 😃
There’s a lot of text under
<div class="error-summary validation-summary-errors">, so instead of trying to assert all of it withassert_exact_text(), you could doassert_text()instead for a substring match:You mentioned something about having “the warning highlighted”? Do you mean
--demomode? That inserts JavaScript into the page, which can make you detected. You can also doself.activate_demo_mode()to activate Demo Mode in the middle of a test.For the 5-second sleep at the end, just add:
self.sleep(5)I’m on it. If I’m able to pull that off and get the job I owe you big time Michael!
Amazing!! thanks so much Michael! have a great one 😃 I was getting this message:
Like this:
If you run it with
python, it will automatically usepytest --uc. If you run it withpytestwithout the--uc, then the line withget_new_driverwill correct it.Also, I didn’t encounter any CAPTCHAs on that site. Maybe they happen later, but if they don’t happen at all, then UC Mode wouldn’t be needed.
aha! of course, done!
Thanks for the explanation! man I really appreciate you taking the time 😃 Watching the selenium conf, pretty cool Michael
behaveis a Python implementation of the Gherkin syntax for BDD. Cucumber is a generic implementation of the Gherkin syntax for BDD.SeleniumBase utilizes the
behaveversion by adding specific code around browser automation:SeleniumBase/examples/behave_bdd
You can also generate
behavescripts from existing tests:pytest --rec-behaveOr use the Recorder to generate
behavescripts:sbase recorder --behave@mdmintz found the
--guioption (i’m on linux). Yes I’m watching the video right now, it’s how I discovered seleniumbase. I’m digging into the doc as well and your other videos. It’s really cool what you have done here! thank you