Skip to content

Commit

Permalink
make visible check for missing elements
Browse files Browse the repository at this point in the history
  • Loading branch information
alltonp committed Aug 13, 2015
1 parent 96802e8 commit 95028f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ case class ElementVisible(by: By) extends Condition {

def expectation = expect("ElementVisible", List(by.toString))
def isSatisfied(browser: UnSafeBrowser) = { browser.isDisplayed(by) == true }
def describeFailure(browser: UnSafeBrowser) = { expectation + butWas(() => "hidden") }
def describeFailure(browser: UnSafeBrowser) = { expectation + butWas(() => if (browser.exists(by)) "hidden" else "does not exist") }
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,11 @@ class ElementVisibleSpec extends WebSpecification with Matchers {
thrown.getMessage should equal("""> FAILED: Assert ElementVisible("Id(ElementVisibleWhenHidden)") but was "hidden" (not met within 2000 millis)""")
}

def `fail for id not exist` {
val id = "ElementVisibleWhenMissing"
val b = given.page(<b>{id}</b>)

val thrown = the [ConditionNotMetException] thrownBy { b.assert(ElementVisible(Id(id))) }
thrown.getMessage should equal(s"""> FAILED: Assert ElementVisible("Id($id)") but was "does not exist" (not met within 2000 millis)""")
}
}

0 comments on commit 95028f4

Please sign in to comment.