Hey everyone, I’m new to Python and Django but have worked with PHP and Symfony before. In that world, I used Behat for behavior-driven development without needing a full Selenium setup. We had this cool thing called GoutteDriver that let us test without firing up a real browser.
Now I’m wondering if there’s something like that for Python, especially when working with Django and Behave. Is there a way to run tests without using Selenium or actual browsers? It would be great to have a lightweight option that doesn’t require the whole browser setup.
I tried looking around but couldn’t find much info. Any suggestions or alternatives you guys use? Thanks in advance for your help!
hey there, have u tried splinter? it’s pretty cool for headless browsing and works nice with behave. it’s like a wrapper for selenium but easier to use. might be worth checkin out if u want something lightweight. i’ve used it for some django projects and it’s been pretty smooth sailing
Have you considered using requests-html? It’s a lightweight alternative that might suit your needs. I’ve used it in several projects as a headless browser solution, and it integrates well with Python and Behave.
requests-html provides HTML parsing capabilities and can execute JavaScript, which is often crucial for modern web applications. It’s not as full-featured as Selenium, but it’s much faster and doesn’t require a browser setup.
For Django specifically, you might want to look into django-webtest. It’s not headless per se, but it’s a good middle ground between Django’s test client and a full browser solution. It simulates requests without the overhead of a real browser.
Both options are worth exploring for your BDD setup. They’re easier to configure and maintain compared to Selenium, especially in CI/CD pipelines.
I’ve been in a similar situation, and I found that using Playwright with Python works wonders for headless browser testing. It’s become my go-to for BDD with Django projects.
Playwright is super fast, supports multiple browsers, and has a really clean API. What I love most is how it handles modern web apps effortlessly - no more struggling with dynamic content or wait times.
For Behave integration, there’s a neat package called pytest-playwright-behave that ties everything together nicely. It lets you write your scenarios in Gherkin and execute them with Playwright’s power under the hood.
The setup is pretty straightforward, and the documentation is solid. Plus, it’s actively maintained, which is always a bonus. Give it a shot - it might be just what you’re looking for to streamline your testing process.