bdd: Wait for finished loads in backforward.
This commit is contained in:
parent
924b0052c6
commit
beab639d7a
@ -5,8 +5,10 @@ Feature: Going back and forward.
|
||||
Given I open data/backforward/1.txt
|
||||
When I open data/backforward/2.txt
|
||||
And I run :back
|
||||
And I wait until data/backforward/1.txt is loaded
|
||||
And I reload
|
||||
And I run :forward
|
||||
And I wait until data/backforward/2.txt is loaded
|
||||
And I reload
|
||||
Then the requests should be:
|
||||
data/backforward/1.txt
|
||||
|
@ -59,6 +59,11 @@ def reload(qtbot, httpbin, quteproc, command):
|
||||
quteproc.send_cmd(':reload')
|
||||
|
||||
|
||||
@bdd.when(bdd.parsers.parse("I wait until {path} is loaded"))
|
||||
def wait_until_loaded(quteproc, path):
|
||||
quteproc.wait_for_load_finished(path)
|
||||
|
||||
|
||||
@bdd.then(bdd.parsers.parse("{path} should be loaded"))
|
||||
def path_should_be_loaded(httpbin, path):
|
||||
requests = httpbin.get_requests()
|
||||
|
@ -192,16 +192,12 @@ class QuteProc(testprocess.Process):
|
||||
self.wait_for(category='config', message='Config option changed: *')
|
||||
|
||||
def open_path(self, path, new_tab=False):
|
||||
url_loaded_pattern = re.compile(
|
||||
r"load status for <qutebrowser.browser.webview.WebView tab_id=\d+ "
|
||||
r"url='[^']+'>: LoadStatus.success")
|
||||
|
||||
url = 'http://localhost:{}/{}'.format(self._httpbin.port, path)
|
||||
if new_tab:
|
||||
self.send_cmd(':open -t ' + url)
|
||||
else:
|
||||
self.send_cmd(':open ' + url)
|
||||
self.wait_for(category='webview', message=url_loaded_pattern)
|
||||
self.wait_for_load_finished(path)
|
||||
|
||||
def mark_expected(self, category=None, loglevel=None, message=None):
|
||||
"""Mark a given logging message as expected."""
|
||||
@ -217,6 +213,14 @@ class QuteProc(testprocess.Process):
|
||||
"""
|
||||
return super().wait_for(timeout, **kwargs)
|
||||
|
||||
def wait_for_load_finished(self, path, timeout=15000):
|
||||
"""Wait until any tab has finished loading."""
|
||||
url = 'http://localhost:{}/{}'.format(self._httpbin.port, path)
|
||||
pattern = re.compile(
|
||||
r"load status for <qutebrowser.browser.webview.WebView tab_id=\d+ "
|
||||
r"url='{}'>: LoadStatus.success".format(url))
|
||||
self.wait_for(category='webview', message=pattern, timeout=timeout)
|
||||
|
||||
def get_session(self):
|
||||
"""Save the session and get the parsed session data."""
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
|
Loading…
Reference in New Issue
Block a user