class CapybaraTestCase(StaticLiveServerTestCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
@capybara.register_driver("selenium_chrome")
def init_selenium_chrome_driver(app):
from capybara.selenium.driver import Driver
options = webdriver.ChromeOptions()
options.add_argument('window-size=1200x600')
options.add_argument('--headless')
options.add_argument('--disable-gpu')
return Driver(app, browser="chrome", options=options)
capybara.default_driver = "selenium_chrome"
capybara.default_max_wait_time = 2
capybara.app_host = cls.live_server_url
cls.driver = capybara.current_session().driver.browser
cls.driver.implicitly_wait(2) # this slows down capybara
@classmethod
def tearDownClass(cls):
cls.driver.quit()
super().tearDownClass()
def tearDown(self):
capybara.reset_sessions()I have two questions:- I have seen that capybara internally creates a Server with a Middleware capable of tracking the current petitions running. Since here I am using an external server (provided by StaticLiveServerTestCase) will there be any problem?
- When using this line cls.driver.implicitly_wait(2)capybara is slowing down. I wanted to give the tests time for the AJAX responses to appear. But seeing the current behaviour I suspect that capybara is handling the wait itself instead of relying on Selenium. Is that right? Should I just set implicity_wait to 0?
Thanks a lot.
To be honest, I have tried another library (splinter) but capybara is much better when handling waits by itself.