Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import java.util.Set;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.core.action.ActionsFactory;
import org.eclipse.che.selenium.core.utils.WaitUtils;
Expand Down Expand Up @@ -394,7 +393,7 @@ public List<WebElement> waitPresenceOfAllElements(By elementsLocator, int timeou
* @param text text for sending
*/
public void waitAndSendKeysTo(By elementLocator, String text) {
waitVisibility(elementLocator).sendKeys(text);
waitAndSendKeysTo(elementLocator, text, DEFAULT_TIMEOUT);
}

/**
Expand Down Expand Up @@ -435,7 +434,19 @@ public void sendKeys(String text) {
* @return text which extracted from element by {@link WebElement#getAttribute(String)}
*/
public String waitVisibilityAndGetValue(By elementLocator) {
return waitVisibility(elementLocator).getAttribute("value");
return waitVisibilityAndGetValue(elementLocator, DEFAULT_TIMEOUT);
}

/**
* Waits during {@code timeout} visibility of {@link WebElement} with specified {@code
* elementLocator} and gets text.
*
* @param elementLocator locator of element from which text should be got
* @param timeout waiting time in seconds
* @return text which extracted from element by {@link WebElement#getAttribute(String)}
*/
public String waitVisibilityAndGetValue(By elementLocator, int timeout) {
return waitVisibilityAndGetAttribute(elementLocator, "value", timeout);
}

/**
Expand All @@ -445,7 +456,18 @@ public String waitVisibilityAndGetValue(By elementLocator) {
* @return text which extracted from element by {@link WebElement#getAttribute(String)}
*/
public String waitVisibilityAndGetValue(WebElement webElement) {
return waitVisibility(webElement).getAttribute("value");
return waitVisibilityAndGetValue(webElement, DEFAULT_TIMEOUT);
}

/**
* Waits during {@code timeout} visibility of provided {@code webElement} and gets text.
*
* @param webElement element, text from which should be got
* @param timeout waiting time in seconds
* @return text which extracted from element by {@link WebElement#getAttribute(String)}
*/
public String waitVisibilityAndGetValue(WebElement webElement, int timeout) {
return waitVisibilityAndGetAttribute(webElement, "value", timeout);
}

/**
Expand Down Expand Up @@ -502,7 +524,7 @@ public String waitVisibilityAndGetAttribute(WebElement element, String attribute
* @return element text by {@link WebElement#getText()}
*/
public String waitVisibilityAndGetText(By elementLocator) {
return waitVisibility(elementLocator).getText();
return waitVisibilityAndGetText(elementLocator, DEFAULT_TIMEOUT);
}

/**
Expand All @@ -524,7 +546,18 @@ public String waitVisibilityAndGetText(By elementLocator, int timeout) {
* @return element text by {@link WebElement#getText()}
*/
public String waitVisibilityAndGetText(WebElement webElement) {
return waitVisibility(webElement).getText();
return waitVisibilityAndGetText(webElement, DEFAULT_TIMEOUT);
}

/**
* Waits during {@code timeout} visibility of provided {@code webElement} and gets text.
*
* @param webElement element from which text should be got
* @param timeout waiting time in seconds
* @return element text by {@link WebElement#getText()}
*/
public String waitVisibilityAndGetText(WebElement webElement, int timeout) {
return waitVisibility(webElement, timeout).getText();
}

/**
Expand All @@ -541,7 +574,7 @@ public void waitValueEqualsTo(By elementLocator, String expectedValue, int timeo
.get(timeout)
.until(
(ExpectedCondition<Boolean>)
driver -> waitVisibilityAndGetValue(elementLocator).equals(expectedValue));
driver -> waitVisibilityAndGetValue(elementLocator, timeout).equals(expectedValue));
}

/**
Expand All @@ -568,7 +601,7 @@ public void waitValueEqualsTo(WebElement webElement, String expectedValue, int t
.get(timeout)
.until(
(ExpectedCondition<Boolean>)
driver -> waitVisibilityAndGetValue(webElement).equals(expectedValue));
driver -> waitVisibilityAndGetValue(webElement, timeout).equals(expectedValue));
}

/**
Expand Down Expand Up @@ -597,7 +630,8 @@ public void waitValueContains(WebElement element, String expectedText, int timeo
.get(timeout)
.until(
(ExpectedCondition<Boolean>)
driver -> waitVisibility(element).getAttribute("value").contains(expectedText));
driver ->
waitVisibility(element, timeout).getAttribute("value").contains(expectedText));
}

/**
Expand Down Expand Up @@ -652,7 +686,7 @@ public void waitTextEqualsTo(By elementLocator, String expectedText, int timeout
.get(timeout)
.until(
(ExpectedCondition<Boolean>)
driver -> waitVisibilityAndGetText(elementLocator).equals(expectedText));
driver -> waitVisibilityAndGetText(elementLocator, timeout).equals(expectedText));
}

/**
Expand All @@ -679,7 +713,7 @@ public void waitTextEqualsTo(WebElement webElement, String expectedText, int tim
.get(timeout)
.until(
(ExpectedCondition<Boolean>)
driver -> waitVisibilityAndGetText(webElement).equals(expectedText));
driver -> waitVisibilityAndGetText(webElement, timeout).equals(expectedText));
}

/**
Expand Down Expand Up @@ -765,7 +799,7 @@ public void waitTextIsNotPresented(WebElement element, String expectedText, int
.get(timeout)
.until(
(ExpectedCondition<Boolean>)
driver -> !(waitVisibilityAndGetText(element).contains(expectedText)));
driver -> !(waitVisibilityAndGetText(element, timeout).contains(expectedText)));
}

/**
Expand Down Expand Up @@ -1081,12 +1115,32 @@ public String switchToIdeFrameAndWaitAvailability(int timeout) {
public void waitOpenedSomeWin() {
webDriverWaitFactory
.get(WIDGET_TIMEOUT_SEC)
.until(
(ExpectedCondition<Boolean>) driver -> seleniumWebDriver.getWindowHandles().size() > 1);
}

/**
* Waits during {@code timeout} until count of opened browser tabs are equals to {@code
* expectedCount}.
*
* @param expectedCount count of the opened browsers tabs
* @param timeout waiting time in seconds
*/
public void waitWindowsCount(int expectedCount, int timeout) {
webDriverWaitFactory
.get(timeout)
.until(
(ExpectedCondition<Boolean>)
input -> {
Set<String> driverWindows = seleniumWebDriver.getWindowHandles();
return (driverWindows.size() > 1);
});
driver -> seleniumWebDriver.getWindowHandles().size() == expectedCount);
}

/**
* Waits until count of opened browser tabs are equals to {@code expectedCount}.
*
* @param expectedCount count of the opened browsers tabs
*/
public void waitWindowsCount(int expectedCount) {
waitWindowsCount(expectedCount, WIDGET_TIMEOUT_SEC);
}

/**
Expand Down