Skip to content

Instantly share code, notes, and snippets.

View slawekradzyminski's full-sized avatar

Slawek Radzyminski slawekradzyminski

View GitHub Profile
@slawekradzyminski
slawekradzyminski / chromePrefs.java
Created February 21, 2016 22:05
chromePrefs.java
chromePrefs.put(BROWSER_NOTIFICATIONS, DISABLED);
@slawekradzyminski
slawekradzyminski / Firefox.java
Created February 21, 2016 22:19
FirefoxWebdriverCaller
private static final PROFILE_DIRECTORY = insert_your_path_here
@Override
public WebDriver getDefaultDriver() {
File profileDirectory = new File(PROFILE_DIRECTORY);
FirefoxProfile profile = new FirefoxProfile(profileDirectory);
profile.setAcceptUntrustedCertificates(true);
profile.setPreference("browser.startup.homepage", "www.google.pl");
return new FirefoxDriver(profile);
Thread.sleep(3000);
WebDriverWait wait = new WebDriverWait(getDriver(), 5, 500);
wait.until(not(presenceOfElementLocated(By.id("disappearingelement"))));
driver.manage().timeouts.implicitWait(10,TimeUnit.SECONDS);
Predicate<WebDriver> loadingElementDisappeared = new Predicate<WebDriver>() {
public boolean apply(WebDriver driver) {
return driver.findElements(By.id("disappearingelement")).size() = 0;
}
};
wait.until(loadingElementDisappeared);
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(5, TimeUnit.SECONDS)
.pollingEvery(500, TimeUnit.MILLISECONDS)
.ignoring(NoSuchElementException.class)
.withMessage("Oops, element didn't disappear!");
public void verifySuccessfulLogin() {
await().until(WAITER_SELECTOR_AFTER_LOGIN).areDisplayed();
}
private Predicate<Fluent> ajaxCallCompleted = new Predicate<Fluent>() {
@Override
public boolean apply(Fluent fluent) {
return (Boolean) ((JavascriptExecutor) getDriver()).executeScript("return (window.jQuery != null) && (jQuery.active === 0);");
}
}
private static final String URL = "https://resttesttest.com/";
private static final String SUCCESS_TEXT = "HTTP 200 OK";