use of org.openqa.selenium.firefox.FirefoxDriver in project ORCID-Source by ORCID.
the class ShibbolethTest method createFireFoxDriverWithModifyHeaders.
private WebDriver createFireFoxDriverWithModifyHeaders(List<Pair<String, String>> headers) throws IOException {
FirefoxProfile fireFoxProfile = new FirefoxProfile();
File modifyHeaders = new File(System.getProperty("user.dir") + "/src/test/resources/modify-headers-0.7.1.1.xpi");
fireFoxProfile.setEnableNativeEvents(false);
fireFoxProfile.addExtension(modifyHeaders);
fireFoxProfile.setPreference("modifyheaders.headers.count", headers.size());
for (int i = 0; i < headers.size(); i++) {
fireFoxProfile.setPreference("modifyheaders.headers.action" + i, "Add");
fireFoxProfile.setPreference("modifyheaders.headers.name" + i, headers.get(i).getLeft());
fireFoxProfile.setPreference("modifyheaders.headers.value" + i, headers.get(i).getRight());
fireFoxProfile.setPreference("modifyheaders.headers.enabled" + i, true);
}
fireFoxProfile.setPreference("modifyheaders.config.active", true);
fireFoxProfile.setPreference("modifyheaders.config.alwaysOn", true);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName("firefox");
capabilities.setPlatform(org.openqa.selenium.Platform.ANY);
capabilities.setCapability(FirefoxDriver.PROFILE, fireFoxProfile);
// Marionette does not allow untrusted certs yet
capabilities.setCapability(FirefoxDriver.MARIONETTE, false);
WebDriver webDriver = new FirefoxDriver(capabilities);
return webDriver;
}
use of org.openqa.selenium.firefox.FirefoxDriver in project Asqatasun by Asqatasun.
the class WebDriverFactory method getFirefoxDriver.
/**
* This methods creates a firefoxDriver instance and set a DISPLAY
* environment variable
* @param display
* @return an instance of firefoxDriver
*/
public FirefoxDriver getFirefoxDriver(String display) {
if (webDriver == null) {
FirefoxBinary ffBinary = new FirefoxBinary();
if (StringUtils.isNotBlank(display)) {
Logger.getLogger(this.getClass()).info("Setting Xvfb display with value " + display);
ffBinary.setEnvironmentProperty("DISPLAY", display);
}
ProfileFactory pf = ProfileFactory.getInstance();
webDriver = new FirefoxDriver(ffBinary, pf.getOnlineProfile());
webDriver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
webDriver.manage().timeouts().pageLoadTimeout(310, TimeUnit.SECONDS);
}
return webDriver;
}
use of org.openqa.selenium.firefox.FirefoxDriver in project SneakerBot by Penor.
the class Adidas method splash.
@SuppressWarnings("deprecation")
public void splash() {
try {
WebDriverWait wait = new WebDriverWait(driver, 60L);
print("Loading webpage: " + url);
driver.get(url);
wait.until(new Function<WebDriver, Boolean>() {
public Boolean apply(WebDriver d) {
// + String.valueOf(((JavascriptExecutor) d).executeScript("return document.readyState")));
return String.valueOf(((JavascriptExecutor) d).executeScript("return document.readyState")).equals("complete");
}
});
//print(driver.getTitle());
//TODO: Get to splash page.
print(proxy != null ? ("[" + proxy.getPassword() + ":" + proxy.getPort() + "] -> ") : "" + "waiting at splash page!");
while (driver.findElement(By.className("sk-fading-circle")).isDisplayed()) Thread.sleep(5000L);
print(proxy != null ? ("[" + proxy.getPassword() + ":" + proxy.getPort() + "] -> ") : "" + "passed splash page!");
driver.manage().getCookies().stream().forEach(c -> {
if (c.getValue().contains("hmac")) {
hmac = c.getValue();
hmacExpiration = c.getExpiry();
}
});
if (driver.findElements(By.className("g-recaptcha")).size() > 0)
siteKey = driver.findElement(By.className("g-recaptcha")).getAttribute("data-sitekey");
if (driver.findElements(By.id("flashproductform")).size() > 0)
clientId = driver.findElement(By.id("flashproductform")).getAttribute("action").split("clientId=")[1];
Date timeLeft = new Date(hmacExpiration.getTime() - System.currentTimeMillis());
print("[Success] -> SiteKey: " + siteKey + " Client ID: " + clientId + " HMAC: " + hmac + " Time Left: " + timeLeft.getMinutes() + "m" + timeLeft.getSeconds() + "s");
if (manual) {
FirefoxProfile profile = new FirefoxProfile();
if (proxy != null) {
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http", proxy.getAddress());
profile.setPreference("network.proxy.http_port", proxy.getPort());
profile.setPreference("network.proxy.ssl", proxy.getAddress());
profile.setPreference("network.proxy.ssl_port", proxy.getPort());
}
//profile.setPreference("general.useragent.override", driver.set);
WebDriver checkout = new FirefoxDriver(profile);
for (Cookie cookie : driver.manage().getCookies()) checkout.manage().addCookie(cookie);
checkout.get(driver.getCurrentUrl());
} else
while (!carted && hmacExpiration.getTime() > System.currentTimeMillis()) atc();
} catch (Exception e) {
String name = e.getClass().getName();
print("[Exception] -> " + name);
carted = true;
if (name.equals("org.openqa.selenium.TimeoutException"))
carted = false;
} finally {
print(carted ? "Closing driver, and ending" : "Failed, Retrying...");
if (carted) {
driver.quit();
Thread.currentThread().interrupt();
}
}
}
use of org.openqa.selenium.firefox.FirefoxDriver in project simba-os by cegeka.
the class Browser method open.
public static void open() {
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.no_proxies_on", "localhost");
profile.setPreference("intl.accept_languages", "en");
browser = new FirefoxDriver(profile);
browser.manage().timeouts().implicitlyWait(TIME_OUT_IN_SECONDS, TimeUnit.SECONDS);
}
use of org.openqa.selenium.firefox.FirefoxDriver in project webpieces by deanhiller.
the class Selenium2Example method main.
public static void main(String[] args) {
// Create a new instance of the Firefox driver
// Notice that the remainder of the code relies on the interface,
// not the implementation.
WebDriver driver = new FirefoxDriver();
// And now use this to visit Google
driver.get("http://www.google.com");
// Alternatively the same thing can be done like this
// driver.navigate().to("http://www.google.com");
// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"));
// Enter something to search for
element.sendKeys("Cheese!");
// Now submit the form. WebDriver will find the form for us from the element
element.submit();
// Check the title of the page
System.out.println("Page title is: " + driver.getTitle());
// Google's search is rendered dynamically with JavaScript.
// Wait for the page to load, timeout after 10 seconds
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().startsWith("cheese!");
}
});
// Should see: "cheese! - Google Search"
System.out.println("Page title is: " + driver.getTitle());
//Close the browser
driver.quit();
}
Aggregations