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);
profile.setAcceptUntrustedCertificates(false);
Thread.sleep(3000);
driver.manage().timeouts.implicitWait(10,TimeUnit.SECONDS);
WebDriverWait wait = new WebDriverWait(getDriver(), 5, 500);
wait.until(not(presenceOfElementLocated(By.id("disappearingelement"))));
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(5, TimeUnit.SECONDS)
.pollingEvery(500, TimeUnit.MILLISECONDS)
.ignoring(NoSuchElementException.class)
.withMessage("Oops, element didn't disappear!");
Predicate<WebDriver> loadingElementDisappeared = new Predicate<WebDriver>() {
public boolean apply(WebDriver driver) {
return driver.findElements(By.id("disappearingelement")).size() = 0;
}
};
wait.until(loadingElementDisappeared);
public void verifySuccessfulLogin() {
await().until(WAITER_SELECTOR_AFTER_LOGIN).areDisplayed();
}