diff --git a/tests/browsertests/common.nim b/tests/browsertests/common.nim index cb16831..340492c 100644 --- a/tests/browsertests/common.nim +++ b/tests/browsertests/common.nim @@ -44,6 +44,10 @@ template check*(session: Session, element: string, let el = session.findElement(element, strategy) check function(el) +template checkIsNone*(session: Session, element: string, strategy=CssSelector) = + let el = session.findElement(element, strategy) + check el.isNone() + template checkText*(session: Session, element, expectedValue: string) = let el = session.findElement(element) check el.isSome() @@ -70,8 +74,9 @@ proc wait*(session: Session, msTimeout: int) = proc logout*(session: Session) = with session: + wait(5000) click "#profile-btn" - click "#logout-btn" + click "#profile-btn #logout-btn" wait(5000) proc login*(session: Session, user, password: string) = diff --git a/tests/browsertests/scenario1.nim b/tests/browsertests/scenario1.nim index d5c2fe5..89dc76b 100644 --- a/tests/browsertests/scenario1.nim +++ b/tests/browsertests/scenario1.nim @@ -15,7 +15,7 @@ proc test*(session: Session, baseUrl: string) = session.checkText("#login-btn", "Log in") test "is empty": - session.check("tr > td.thread-title", isNone) + session.checkIsNone("tr > td.thread-title") # Logging in test "can login/logout": diff --git a/tests/browsertests/threads.nim b/tests/browsertests/threads.nim index 4a26148..5181b11 100644 --- a/tests/browsertests/threads.nim +++ b/tests/browsertests/threads.nim @@ -80,6 +80,7 @@ proc test*(session: Session, baseUrl: string) = test "can delete thread": with session: + wait() click titleStr, LinkTextSelector wait() @@ -90,6 +91,8 @@ proc test*(session: Session, baseUrl: string) = click "#delete-modal .delete-btn" # Make sure the forum post is gone - check titleStr, LinkTextSelector, isNone + checkIsNone titleStr, LinkTextSelector + session.navigate(baseUrl) + waitForLoad(session) logout(session)