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);
}
}
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);
}
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;
}
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;
}
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;
}
Aggregations