com.automation.remarks.kirk.Element.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kirk Show documentation
Show all versions of kirk Show documentation
Kirk - pragmatic UI test automation
package com.automation.remarks.kirk
import com.automation.remarks.kirk.conditions.Condition
import com.automation.remarks.kirk.conditions.not
import com.automation.remarks.kirk.core.waitFor
import com.automation.remarks.kirk.locators.ElementLocator
import org.openqa.selenium.WebDriver
/**
* Created by sergey on 09.07.17.
*/
abstract class Element(protected val locator: ElementLocator,
protected val driver: WebDriver) {
var waitTimeout: Int = 4000
var waitPoolingInterval: Double = 0.1
var eventListener: KirkEventListener? = null
protected fun should(condition: Condition, waitTimeout: Int) {
try {
waitFor(driver, this.locator, condition, waitTimeout, waitPoolingInterval)
} catch (ex: Exception) {
eventListener?.onFail(ex)
throw ex
}
}
protected fun should(condition: Condition) {
should(condition, waitTimeout)
}
protected fun shouldNot(condition: Condition) {
should(not(condition))
}
infix fun shouldHave(condition: Condition) {
should(condition)
}
fun shouldBe(condition: Condition) {
should(condition)
}
fun shouldNotHave(condition: Condition) {
shouldNot(condition)
}
fun shouldNotBe(condition: Condition) {
shouldNot(condition)
}
}