Search in sources :

Example 1 with AbstractPage

use of com.qaprosoft.carina.core.gui.AbstractPage in project carina by qaprosoft.

the class DriverHelper method isPageOpened.

public boolean isPageOpened(final AbstractPage page, long timeout) {
    boolean result;
    final WebDriver drv = getDriver();
    Wait<WebDriver> wait = new WebDriverWait(drv, timeout, RETRY_TIME);
    try {
        wait.until((Function<WebDriver, Object>) dr -> LogicUtils.isURLEqual(page.getPageURL(), drv.getCurrentUrl()));
        result = true;
    } catch (Exception e) {
        result = false;
    }
    if (!result) {
        LOGGER.warn(String.format("Actual URL differs from expected one. Expected '%s' but found '%s'", page.getPageURL(), drv.getCurrentUrl()));
    }
    return result;
}
Also used : WebDriver(org.openqa.selenium.WebDriver) EventFiringWebDriver(org.openqa.selenium.support.events.EventFiringWebDriver) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) HttpURLConnection(java.net.HttpURLConnection) SpecialKeywords(com.qaprosoft.carina.core.foundation.commons.SpecialKeywords) URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) WebElement(org.openqa.selenium.WebElement) JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) Matcher(java.util.regex.Matcher) AbstractPage(com.qaprosoft.carina.core.gui.AbstractPage) Duration(java.time.Duration) Actions(org.openqa.selenium.interactions.Actions) Parameter(com.qaprosoft.carina.core.foundation.utils.Configuration.Parameter) ExpectedConditions(org.openqa.selenium.support.ui.ExpectedConditions) java.util.concurrent(java.util.concurrent) MethodHandles(java.lang.invoke.MethodHandles) List(java.util.List) TimeoutException(org.openqa.selenium.TimeoutException) CryptoTool(com.qaprosoft.carina.core.foundation.crypto.CryptoTool) JavascriptException(org.openqa.selenium.JavascriptException) NoSuchSessionException(org.openqa.selenium.NoSuchSessionException) Pattern(java.util.regex.Pattern) DriverListener(com.qaprosoft.carina.core.foundation.webdriver.listener.DriverListener) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) ScriptTimeoutException(org.openqa.selenium.ScriptTimeoutException) java.util(java.util) Wait(org.openqa.selenium.support.ui.Wait) DataFlavor(java.awt.datatransfer.DataFlavor) WebDriver(org.openqa.selenium.WebDriver) WebDriverException(org.openqa.selenium.WebDriverException) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) Configuration(com.qaprosoft.carina.core.foundation.utils.Configuration) ExtendedWebElement(com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement) UnhandledAlertException(org.openqa.selenium.UnhandledAlertException) Action(org.openqa.selenium.interactions.Action) Function(java.util.function.Function) Supplier(java.util.function.Supplier) CommonUtils(com.qaprosoft.carina.core.foundation.utils.common.CommonUtils) Assert(org.testng.Assert) JsonException(org.openqa.selenium.json.JsonException) NoAlertPresentException(org.openqa.selenium.NoAlertPresentException) LogicUtils(com.qaprosoft.carina.core.foundation.utils.LogicUtils) EventFiringWebDriver(org.openqa.selenium.support.events.EventFiringWebDriver) Messager(com.qaprosoft.carina.core.foundation.utils.Messager) Logger(org.slf4j.Logger) MalformedURLException(java.net.MalformedURLException) Keys(org.openqa.selenium.Keys) By(org.openqa.selenium.By) IOException(java.io.IOException) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) InputStreamReader(java.io.InputStreamReader) java.awt(java.awt) NoSuchElementException(org.openqa.selenium.NoSuchElementException) FluentWait(org.openqa.selenium.support.ui.FluentWait) Cookie(org.openqa.selenium.Cookie) BufferedReader(java.io.BufferedReader) NoSuchWindowException(org.openqa.selenium.NoSuchWindowException) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) TimeoutException(org.openqa.selenium.TimeoutException) JavascriptException(org.openqa.selenium.JavascriptException) NoSuchSessionException(org.openqa.selenium.NoSuchSessionException) ScriptTimeoutException(org.openqa.selenium.ScriptTimeoutException) WebDriverException(org.openqa.selenium.WebDriverException) UnhandledAlertException(org.openqa.selenium.UnhandledAlertException) JsonException(org.openqa.selenium.json.JsonException) NoAlertPresentException(org.openqa.selenium.NoAlertPresentException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) NoSuchElementException(org.openqa.selenium.NoSuchElementException) NoSuchWindowException(org.openqa.selenium.NoSuchWindowException)

Aggregations

SpecialKeywords (com.qaprosoft.carina.core.foundation.commons.SpecialKeywords)1 CryptoTool (com.qaprosoft.carina.core.foundation.crypto.CryptoTool)1 Configuration (com.qaprosoft.carina.core.foundation.utils.Configuration)1 Parameter (com.qaprosoft.carina.core.foundation.utils.Configuration.Parameter)1 LogicUtils (com.qaprosoft.carina.core.foundation.utils.LogicUtils)1 Messager (com.qaprosoft.carina.core.foundation.utils.Messager)1 CommonUtils (com.qaprosoft.carina.core.foundation.utils.common.CommonUtils)1 ExtendedWebElement (com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement)1 DriverListener (com.qaprosoft.carina.core.foundation.webdriver.listener.DriverListener)1 AbstractPage (com.qaprosoft.carina.core.gui.AbstractPage)1 java.awt (java.awt)1 DataFlavor (java.awt.datatransfer.DataFlavor)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 MethodHandles (java.lang.invoke.MethodHandles)1 HttpURLConnection (java.net.HttpURLConnection)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Duration (java.time.Duration)1