Skip to content

Commit

Permalink
Add FluentWait for avoiding unexpected fails for animated web element (
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Musienko authored and dmytro-ndp committed Dec 22, 2017
1 parent fdb717f commit 3519f09
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
*/
package org.eclipse.che.selenium.pageobject;

import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.ATTACHING_ELEM_TO_DOM_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.ELEMENT_TIMEOUT_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.LOAD_PAGE_TIMEOUT_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.WIDGET_TIMEOUT_SEC;
import static org.openqa.selenium.support.ui.ExpectedConditions.elementToBeClickable;
import static org.openqa.selenium.support.ui.ExpectedConditions.invisibilityOfElementLocated;
import static org.openqa.selenium.support.ui.ExpectedConditions.textToBe;
import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOf;
Expand All @@ -23,9 +25,13 @@
import com.google.inject.Singleton;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.FluentWait;
import org.openqa.selenium.support.ui.Wait;
import org.openqa.selenium.support.ui.WebDriverWait;

/**
Expand Down Expand Up @@ -231,8 +237,11 @@ public void waitRepoUrl(String url) {
}

public void openPullRequestOnGitHub() {
loadPageDriverWait
.until(elementToBeClickable(By.xpath(PullRequestLocators.OPEN_GITHUB_BTN)))
.click();
Wait<WebDriver> wait =
new FluentWait(seleniumWebDriver)
.withTimeout(ATTACHING_ELEM_TO_DOM_SEC, SECONDS)
.pollingEvery(500, MILLISECONDS)
.ignoring(WebDriverException.class);
wait.until(visibilityOfElementLocated(By.xpath(PullRequestLocators.OPEN_GITHUB_BTN))).click();
}
}

0 comments on commit 3519f09

Please sign in to comment.