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

com.automation.remarks.kirk.Element.kt Maven / Gradle / Ivy

There is a newer version: 0.8.5
Show newest version
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)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy