Util for Selenium that waits for page change
partially implements bp assign-category-button Change-Id: I3a96b9269c2bb88186797ab4b1f4629cf014aefe
This commit is contained in:
parent
4a4d929408
commit
52932566c9
@ -17,6 +17,7 @@ import yaml
|
|||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
from selenium.webdriver.support import wait
|
||||||
|
|
||||||
import config.config as cfg
|
import config.config as cfg
|
||||||
from muranodashboard.tests.functional import consts
|
from muranodashboard.tests.functional import consts
|
||||||
@ -113,3 +114,22 @@ def compose_bundle(bundle_path, app_names):
|
|||||||
|
|
||||||
def glare_enabled():
|
def glare_enabled():
|
||||||
return cfg.common.packages_service == "glare"
|
return cfg.common.packages_service == "glare"
|
||||||
|
|
||||||
|
|
||||||
|
class wait_for_page_change(object):
|
||||||
|
"""Waits until current page change in a browser."""
|
||||||
|
def __init__(self, driver, timeout=30):
|
||||||
|
self.driver = driver
|
||||||
|
self.timeout = timeout
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
self.old_page = self.driver.find_element_by_tag_name('html')
|
||||||
|
|
||||||
|
def page_has_loaded(self):
|
||||||
|
new_page = self.driver.find_element_by_tag_name('html')
|
||||||
|
return new_page.id != self.old_page.id
|
||||||
|
|
||||||
|
def __exit__(self, *_):
|
||||||
|
wait.WebDriverWait(self.driver, timeout=self.timeout).until(
|
||||||
|
lambda _: self.page_has_loaded()
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user