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
|
Given I open data/backforward/1.txt
|
||||||
When I open data/backforward/2.txt
|
When I open data/backforward/2.txt
|
||||||
And I run :back
|
And I run :back
|
||||||
|
And I wait until data/backforward/1.txt is loaded
|
||||||
And I reload
|
And I reload
|
||||||
And I run :forward
|
And I run :forward
|
||||||
|
And I wait until data/backforward/2.txt is loaded
|
||||||
And I reload
|
And I reload
|
||||||
Then the requests should be:
|
Then the requests should be:
|
||||||
data/backforward/1.txt
|
data/backforward/1.txt
|
||||||
|
@ -59,6 +59,11 @@ def reload(qtbot, httpbin, quteproc, command):
|
|||||||
quteproc.send_cmd(':reload')
|
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"))
|
@bdd.then(bdd.parsers.parse("{path} should be loaded"))
|
||||||
def path_should_be_loaded(httpbin, path):
|
def path_should_be_loaded(httpbin, path):
|
||||||
requests = httpbin.get_requests()
|
requests = httpbin.get_requests()
|
||||||
|
@ -192,16 +192,12 @@ class QuteProc(testprocess.Process):
|
|||||||
self.wait_for(category='config', message='Config option changed: *')
|
self.wait_for(category='config', message='Config option changed: *')
|
||||||
|
|
||||||
def open_path(self, path, new_tab=False):
|
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)
|
url = 'http://localhost:{}/{}'.format(self._httpbin.port, path)
|
||||||
if new_tab:
|
if new_tab:
|
||||||
self.send_cmd(':open -t ' + url)
|
self.send_cmd(':open -t ' + url)
|
||||||
else:
|
else:
|
||||||
self.send_cmd(':open ' + url)
|
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):
|
def mark_expected(self, category=None, loglevel=None, message=None):
|
||||||
"""Mark a given logging message as expected."""
|
"""Mark a given logging message as expected."""
|
||||||
@ -217,6 +213,14 @@ class QuteProc(testprocess.Process):
|
|||||||
"""
|
"""
|
||||||
return super().wait_for(timeout, **kwargs)
|
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):
|
def get_session(self):
|
||||||
"""Save the session and get the parsed session data."""
|
"""Save the session and get the parsed session data."""
|
||||||
with tempfile.TemporaryDirectory() as tmpdir:
|
with tempfile.TemporaryDirectory() as tmpdir:
|
||||||
|
Loading…
Reference in New Issue
Block a user