This commit implements STUD-1490, allowing creation of components on the container page. It also enables the delete and duplicate buttons now that new content can be created that would benefit. Note that it also creates shared functionality for adding components, and refactors the unit page to use it too.
36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
"""
|
|
Utility methods useful for Studio page tests.
|
|
"""
|
|
from bok_choy.promise import Promise
|
|
from selenium.webdriver.common.action_chains import ActionChains
|
|
|
|
|
|
def click_css(page, css, source_index, require_notification=True):
|
|
"""
|
|
Click the button/link with the given css and index on the specified page (subclass of PageObject).
|
|
|
|
If require_notification is False (default value is True), the method will return immediately.
|
|
Otherwise, it will wait for the "mini-notification" to appear and disappear.
|
|
"""
|
|
buttons = page.q(css=css)
|
|
target = buttons[source_index]
|
|
ActionChains(page.browser).click(target).release().perform()
|
|
if require_notification:
|
|
wait_for_notification(page)
|
|
|
|
|
|
def wait_for_notification(page):
|
|
"""
|
|
Waits for the "mini-notification" to appear and disappear on the given page (subclass of PageObject).
|
|
"""
|
|
def _is_saving():
|
|
num_notifications = len(page.q(css='.wrapper-notification-mini.is-shown'))
|
|
return (num_notifications == 1, num_notifications)
|
|
|
|
def _is_saving_done():
|
|
num_notifications = len(page.q(css='.wrapper-notification-mini.is-hiding'))
|
|
return (num_notifications == 1, num_notifications)
|
|
|
|
Promise(_is_saving, 'Notification showing.').fulfill()
|
|
Promise(_is_saving_done, 'Notification hidden.').fulfill()
|