All Downloads are FREE. Search and download functionalities are using the official Maven repository.

im.yagni.driveby.conditions.ElementOrder.scala Maven / Gradle / Ivy

The newest version!
package im.yagni.driveby.conditions

import im.yagni.driveby.browser.UnSafeBrowser
import im.yagni.driveby.{By, Condition, Describer}

object ElementOrder {
  import Describer._

  def apply(first: By, second: By) = new Condition {
    def expectation = expect("ElementOrder", List(first + " location is above " + second))
    def isSatisfied(browser: UnSafeBrowser) = firstElementIsAboveSecondElement(first, second, browser)
    def describeFailure(browser: UnSafeBrowser) = expectation + butWas(() => "firstYLocation: " + yAxisLocation(browser, first) + " secondYLocation: " + yAxisLocation(browser, second) )

    private def firstElementIsAboveSecondElement(first: By, second: By, browser: UnSafeBrowser) = yAxisLocation(browser, first) < yAxisLocation(browser, second)
    private def yAxisLocation(browser: UnSafeBrowser, by: By) = browser.findUniqueElement(by).yAxisLocation
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy