diff --git a/tests/WebSpec.hs b/tests/WebSpec.hs index a877c7b..8454b96 100644 --- a/tests/WebSpec.hs +++ b/tests/WebSpec.hs @@ -155,10 +155,7 @@ categoryTests = session "categories" $ using [chromeCaps] $ do sel <- select (form :// ByName "status") opt <- select (sel :// HasText "Complete") selectDropdown sel opt - click (form :// ".save") - -- normally Selenium wouldn't wait for the request to complete, so we - -- have to wait manually by waiting until the form is hidden - checkNotPresent form + saveForm form onAnotherPage "/" $ do ("div" : Text -> s -> WD () @@ -565,6 +562,18 @@ openItemEcosystemEditForm item = do click (item :// ".item-ecosystem .normal .edit-item-ecosystem") select (item :// ".item-ecosystem .editing") +-- | Save a form and wait for it to close. +-- +-- Assumes that the form has a button with class @save@. +saveForm :: CanSelect s => s -> WD () +saveForm form = do + click (form :// ".save") + -- Normally Selenium wouldn't wait for the “save” request to complete, so + -- we have to manually wait until the form is hidden. It's important + -- because otherwise things like issue #134 happen (when Selenium asks for + -- another page before the form has finished saving). + checkNotPresent form + ----------------------------------------------------------------------------- -- Utilities for webdriver -----------------------------------------------------------------------------