Search in sources :

Example 11 with WebDriverException

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

the class EmailUtils method getPasswordResetLinkFromEmailContent.

public static String getPasswordResetLinkFromEmailContent(String mailContent) {
    /*
      remove "=" character except when followed by "3D" hex sequence
      and replace "=3D" sequence with a single "=" character
      because of RFC-2045 line breaks and encoding in IMAP
      see: https://tools.ietf.org/html/rfc2045#section-6.7
    */
    String formattedContent = mailContent.replaceAll("=(?!3D)", "").replaceAll("=3D", "=");
    Matcher m = PASSWORD_RESET_PATTERN.matcher(formattedContent);
    if (m.find()) {
        return m.group("url");
    } else {
        throw new WebDriverException("There was no match in the following content: \n" + formattedContent);
    }
}
Also used : Matcher(java.util.regex.Matcher) WebDriverException(org.openqa.selenium.WebDriverException)

Example 12 with WebDriverException

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

the class AdsBaseObject method verifyAdVisibleInSlot.

protected void verifyAdVisibleInSlot(String slotSelector, WebElement slot) {
    if (!checkIfSlotExpanded(slot)) {
        Optional<WebElement> lastGptDiv = getLastGptDiv(slotSelector);
        if (lastGptDiv.isPresent() && checkIfGptSlotHasCreativeContent(lastGptDiv.get(), HOP_AD_TYPE)) {
            PageObjectLogging.log("verifyAdVisibleInSlot", "Slot has " + HOP_AD_TYPE, true);
            return;
        }
        throw new WebDriverException(slot.getAttribute("id") + " is collapsed");
    }
    boolean adVisible = new AdsComparison().isAdVisible(slot, slotSelector, driver);
    extractGptInfo(slotSelector);
    if (!adVisible) {
        throw new WebDriverException("Ad is not present in " + slotSelector);
    }
    PageObjectLogging.log("ScreenshotsComparison", "Ad is present in " + slotSelector, true);
}
Also used : AdsComparison(com.wikia.webdriver.pageobjectsfactory.pageobject.adsbase.helpers.AdsComparison) WebElement(org.openqa.selenium.WebElement) WebDriverException(org.openqa.selenium.WebDriverException)

Example 13 with WebDriverException

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

the class SpecialBlockListPage method isUserBlocked.

/**
   * this method checks if specified user is currently blocked
   *
   * @param username user to be checked
   * @return boolean value with the answer for the question
   */
public boolean isUserBlocked(String username) {
    boolean isBlocked = false;
    searchForUser(username);
    if (!isElementOnPage(expirationDateElement)) {
        return isBlocked;
    }
    SimpleDateFormat blockListDateFormat = new SimpleDateFormat("HH:mm, MMMM dd, yyyy", Locale.US);
    String expirationDateText = expirationDateElement.getText();
    try {
        Date expirationDate = blockListDateFormat.parse(expirationDateText);
        Date currentDate = new Date();
        isBlocked = currentDate.before(expirationDate);
    } catch (ParseException ex) {
        throw new WebDriverException("Can't parse expirationDateText: " + expirationDateText);
    }
    PageObjectLogging.log("isUserBlocked", "user is" + (isBlocked ? " blocked" : "n't blocked"), true);
    return isBlocked;
}
Also used : ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) WebDriverException(org.openqa.selenium.WebDriverException)

Example 14 with WebDriverException

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

the class SpecialPromotePageObject method getUploadedImage.

/**
   * This method creates a file in the process. recomended: after call, delete the physical file
   * using file.delete()
   *
   * @return file uploaded as main thumbnail on special:Promote
   */
public File getUploadedImage() {
    wait.forElementVisible(thumbnailImage);
    File uploadedImageFile = new File(PageContent.IMAGE_UPLOAD_RESOURCES_PATH + "shouldBeDeleted.png");
    try {
        URL url = new URL(thumbnailImage.getAttribute("src"));
        BufferedImage bufImgOne = ImageIO.read(url);
        ImageIO.write(bufImgOne, "png", uploadedImageFile);
    } catch (IOException e) {
        throw new WebDriverException();
    }
    return uploadedImageFile;
}
Also used : IOException(java.io.IOException) File(java.io.File) URL(java.net.URL) BufferedImage(java.awt.image.BufferedImage) WebDriverException(org.openqa.selenium.WebDriverException)

Example 15 with WebDriverException

use of org.openqa.selenium.WebDriverException in project geode by apache.

the class PulseTestUtils method clickElementUsingId.

public static void clickElementUsingId(String id) {
    WebDriverException lastException = null;
    int attempts = 3;
    while (attempts > 0) {
        try {
            waitForElementWithId(id).click();
            return;
        } catch (StaleElementReferenceException sere) {
            lastException = sere;
        }
        attempts++;
    }
    throw lastException;
}
Also used : StaleElementReferenceException(org.openqa.selenium.StaleElementReferenceException) WebDriverException(org.openqa.selenium.WebDriverException)

Aggregations

WebDriverException (org.openqa.selenium.WebDriverException)28 IOException (java.io.IOException)16 File (java.io.File)8 Matcher (java.util.regex.Matcher)4 URISyntaxException (java.net.URISyntaxException)3 Pattern (java.util.regex.Pattern)3 ClientProtocolException (org.apache.http.client.ClientProtocolException)3 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)3 Gson (com.google.gson.Gson)2 TypeToken (com.google.gson.reflect.TypeToken)2 User (com.wikia.webdriver.common.core.helpers.User)2 AdsComparison (com.wikia.webdriver.pageobjectsfactory.pageobject.adsbase.helpers.AdsComparison)2 BufferedImage (java.awt.image.BufferedImage)2 Method (java.lang.reflect.Method)2 URL (java.net.URL)2 NoSuchElementException (java.util.NoSuchElementException)2 HttpResponse (org.apache.http.HttpResponse)2 UrlEncodedFormEntity (org.apache.http.client.entity.UrlEncodedFormEntity)2 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)2 HttpPost (org.apache.http.client.methods.HttpPost)2