use of org.openqa.selenium.WebDriverException in project selenium-tests by Wikia.
the class ImageEditor method saveImageFile.
public void saveImageFile(File imageFile, String path) {
Pattern pattern = Pattern.compile("/*.jpg|/*.png|/*.jpeg");
Matcher matcher = pattern.matcher(path);
String newPath = null;
if (!matcher.matches()) {
newPath = path + ".png";
}
try {
FileUtils.copyFile(imageFile, new File(newPath));
} catch (IOException e) {
throw new WebDriverException(e);
}
}
use of org.openqa.selenium.WebDriverException in project selenium-tests by Wikia.
the class NetworkTrafficInterceptor method logDFP.
/**
* Looks for correlator pattern in requests query strings to DFP domain, and logs if all the calls
* have the same correlator ID. Any difference is ID is logged as failure.
*/
public void logDFP(String skinCorrelator) {
har = getHar();
String expectedCorrelator = null;
Pattern pt = Pattern.compile("(correlator=)\\d*");
for (HarEntry entry : har.getLog().getEntries()) {
if (entry.getRequest().getUrl().contains("pubads.g.doubleclick.net") && entry.getRequest().getQueryString().toString().contains(skinCorrelator)) {
Matcher matcher = pt.matcher(entry.getRequest().getQueryString().toString());
if (matcher.find()) {
String correlatorID = matcher.group(0);
if (expectedCorrelator == null) {
expectedCorrelator = correlatorID;
}
PageObjectLogging.log("CORRELATOR CHECK", "CORRELATOR ID: " + correlatorID, correlatorID.equals(expectedCorrelator));
} else {
throw new WebDriverException("Missing correlator param in query string");
}
}
}
}
use of org.openqa.selenium.WebDriverException in project selenium-tests by Wikia.
the class Helios method deleteAllTokens.
public static void deleteAllTokens(User user) {
String heliosGetTokenURL = HeliosConfig.getUrl(HeliosConfig.HeliosController.USERS);
HttpDelete httpDelete = new HttpDelete(String.format("%s/%s/tokens", heliosGetTokenURL, user.getUserId()));
httpDelete.setHeader("THE-SCHWARTZ", Configuration.getCredentials().apiToken);
CloseableHttpResponse response = null;
try {
response = getDefaultClient().execute(httpDelete);
PageObjectLogging.log("DELETE HEADERS: ", response.toString(), true);
} catch (ClientProtocolException e) {
PageObjectLogging.log("CLIENT PROTOCOL EXCEPTION", ExceptionUtils.getStackTrace(e), false);
throw new WebDriverException(e);
} catch (IOException e) {
PageObjectLogging.log(IOEXCEPTION_COMMAND, IOEXCEPTION_ERROR_MESSAGE + ExceptionUtils.getStackTrace(e), false);
throw new WebDriverException(e);
}
}
use of org.openqa.selenium.WebDriverException in project selenium-tests by Wikia.
the class ApiCall method call.
public void call() {
try {
URL url = new URL(getURL());
CloseableHttpClient httpClient = HttpClientBuilder.create().disableAutomaticRetries().build();
HttpPost httpPost = getHtppPost(url);
// set header
if (getUser() != null) {
httpPost.addHeader("X-Wikia-AccessToken", Helios.getAccessToken(getUser()));
}
// set query params
if (getParams() != null) {
httpPost.setEntity(new UrlEncodedFormEntity(getParams(), StandardCharsets.UTF_8));
}
httpClient.execute(httpPost);
PageObjectLogging.log("CONTENT PUSH", "Content posted to: " + getURL(), true);
} catch (ClientProtocolException e) {
PageObjectLogging.log("EXCEPTION", ExceptionUtils.getStackTrace(e), false);
throw new WebDriverException(ERROR_MESSAGE);
} catch (IOException e) {
PageObjectLogging.log("IO EXCEPTION", ExceptionUtils.getStackTrace(e), false);
throw new WebDriverException(ERROR_MESSAGE);
} catch (URISyntaxException e) {
PageObjectLogging.log("URI_SYNTAX EXCEPTION", ExceptionUtils.getStackTrace(e), false);
throw new WebDriverException(ERROR_MESSAGE);
}
}
use of org.openqa.selenium.WebDriverException in project selenium-tests by Wikia.
the class EmailUtils method getFirstEmailContent.
public static String getFirstEmailContent(String userName, String password, String subject) {
try {
PageObjectLogging.logInfo("Checking emails for " + userName + " that contain '" + subject + "'");
// establishing connections
Properties props = System.getProperties();
props.setProperty("mail.store.protocol", "imaps");
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imaps");
store.connect("imap.googlemail.com", userName, password);
// getInbox
Folder inbox = store.getFolder("Inbox");
inbox.open(Folder.READ_ONLY);
Message[] messages = null;
boolean forgottenPasswordMessageFound = false;
Message magicMessage = null;
for (int i = 0; !forgottenPasswordMessageFound; i++) {
messages = inbox.getMessages();
PageObjectLogging.log("Mail", "Waiting for the message", true);
Thread.sleep(2000);
for (Message message : messages) {
if (message.getSubject().contains(subject)) {
forgottenPasswordMessageFound = true;
magicMessage = message;
}
}
if (i > 15) {
throw new WebDriverException("Mail timeout exceeded");
}
}
PageObjectLogging.log("Mail", "Mail arrived", true);
Message m = magicMessage;
String line;
StringBuilder builder = new StringBuilder();
InputStreamReader in = new InputStreamReader(m.getInputStream());
BufferedReader reader = new BufferedReader(in);
while ((line = reader.readLine()) != null) {
builder.append(line);
}
store.close();
return builder.toString();
} catch (NoSuchProviderException e) {
PageObjectLogging.log("getFirstEmailContent", e, false);
throw new WebDriverException();
} catch (MessagingException | IOException | InterruptedException e) {
PageObjectLogging.log("getFirstEmailContent", e, false);
throw new WebDriverException();
}
}
Aggregations