Search in sources :

Example 66 with WebDriver

use of org.openqa.selenium.WebDriver in project selenium-tests by Wikia.

the class FacebookSignupModalComponentObject method acceptWikiaAppPolicyNoEmail.

public void acceptWikiaAppPolicyNoEmail() {
    new WebDriverWait(driver, 10).until(new ExpectedCondition<Boolean>() {

        @Nullable
        @Override
        public Boolean apply(WebDriver input) {
            return input.getWindowHandles().size() > 1;
        }
    });
    Object[] handles = driver.getWindowHandles().toArray();
    driver.switchTo().window(handles[1].toString());
    wait.forElementVisible(By.cssSelector("button[name='__CONFIRM__']"));
    appTermsConfirmButton.click();
    driver.switchTo().window(handles[0].toString());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) WikiBasePageObject(com.wikia.webdriver.pageobjectsfactory.pageobject.WikiBasePageObject) Nullable(javax.annotation.Nullable)

Example 67 with WebDriver

use of org.openqa.selenium.WebDriver in project selenium-tests by Wikia.

the class DropDownComponentObject method openDropDown.

/**
   * Open dropdown - we need to move mouse outside the element and move back to element to trigger
   * the event
   */
public DropDownComponentObject openDropDown() {
    driver.manage().timeouts().implicitlyWait(500, TimeUnit.MILLISECONDS);
    try {
        new WebDriverWait(driver, 20, 2000).until(new ExpectedCondition<Boolean>() {

            @Override
            public Boolean apply(WebDriver webDriver) {
                if (!driver.findElement(By.cssSelector(LOGIN_DROPDOWN_TRIGGER_CSS)).getAttribute("class").contains("active")) {
                    ((JavascriptExecutor) driver).executeScript("$j('.ajaxLogin .avatar-container').trigger('click')");
                    return false;
                }
                return true;
            }
        });
    } finally {
        restoreDefaultImplicitWait();
    }
    PageObjectLogging.log("DropdownVisible", "Login dropdown is visible", true, driver);
    return this;
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait)

Example 68 with WebDriver

use of org.openqa.selenium.WebDriver in project selenium-tests by Wikia.

the class TopNoteModalDialog method clickApprove.

public void clickApprove() {
    super.clickConfirm();
    new WebDriverWait(driver, DiscussionsConstants.TIMEOUT).until((Predicate<WebDriver>) input -> !post.getAttribute("class").contains("is-reported"));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) Predicate(com.google.common.base.Predicate) WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) FindBy(org.openqa.selenium.support.FindBy) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait)

Example 69 with WebDriver

use of org.openqa.selenium.WebDriver in project selenium-tests by Wikia.

the class DeleteDialog method confirmAndWait.

public void confirmAndWait() {
    super.clickConfirm();
    new WebDriverWait(driver, DiscussionsConstants.TIMEOUT).until((Predicate<WebDriver>) input -> postList.stream().allMatch(p -> p.getAttribute("class").contains("is-deleted")));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) List(java.util.List) Predicate(com.google.common.base.Predicate) WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) FindBy(org.openqa.selenium.support.FindBy) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait)

Example 70 with WebDriver

use of org.openqa.selenium.WebDriver in project selenium-tests by Wikia.

the class AdsComparison method isAdVisible.

public boolean isAdVisible(final WebElement element, final String selector, final WebDriver driver) {
    hideSlot(selector, driver);
    final BufferedImage backgroundImg = shooter.takeScreenshot(element, driver);
    PageObjectLogging.log("ScreenshotsComparison", "Background image in " + selector, true, driver);
    showSlot(selector, driver);
    try {
        WebDriverWait wait = new WebDriverWait(driver, AD_TIMEOUT_SEC);
        wait.until(new ExpectedCondition<Object>() {

            @Override
            public Object apply(WebDriver driver) {
                BufferedImage adImg = shooter.takeScreenshot(element, driver);
                PageObjectLogging.log("ScreenshotsComparison", "Ad image in " + selector, true);
                if (adImg.getHeight() == 1 || imageComparison.isMonocolorImage(adImg)) {
                    return false;
                }
                return imageComparison.areImagesDifferent(backgroundImg, adImg, IMAGES_THRESHOLD_PERCENT);
            }
        });
    } catch (TimeoutException e) {
        PageObjectLogging.logWarning("ScreenshotsComparison", e);
        return false;
    }
    return true;
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) BufferedImage(java.awt.image.BufferedImage) TimeoutException(org.openqa.selenium.TimeoutException)

Aggregations

WebDriver (org.openqa.selenium.WebDriver)167 WebElement (org.openqa.selenium.WebElement)87 Test (org.junit.Test)61 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)59 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)40 Actions (org.openqa.selenium.interactions.Actions)25 IOException (java.io.IOException)12 Cookie (org.openqa.selenium.Cookie)11 List (java.util.List)10 File (java.io.File)9 HttpRequestCallback (ghostdriver.server.HttpRequestCallback)8 HttpServletRequest (javax.servlet.http.HttpServletRequest)8 HttpServletResponse (javax.servlet.http.HttpServletResponse)8 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)8 ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)7 ExpectedCondition (org.openqa.selenium.support.ui.ExpectedCondition)7 By (org.openqa.selenium.By)5 Dimension (org.openqa.selenium.Dimension)5 Predicate (com.google.common.base.Predicate)4 TimeoutException (org.openqa.selenium.TimeoutException)4