Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Crawljax setup with custom browser builder that sets a Cookie.
public class Test {
static class MyProvider implements Provider<EmbeddedBrowser> {
@Override
public EmbeddedBrowser get() {
EmbeddedBrowser browser2;
browser2 = newFireFoxBrowser();
return browser2;
}
private EmbeddedBrowser newFireFoxBrowser() {
FirefoxProfile profile = new FirefoxProfile();
WebDriver drivertest = new FirefoxDriver(profile);
Cookie test1 = new Cookie("a", "1234");
drivertest.manage().addCookie(test1);
return WebDriverBackedEmbeddedBrowser.withDriver(drivertest);
}
}
public static void main(String[] args) {
BrowserConfiguration browserConfg =
new BrowserConfiguration(BrowserType.FIREFOX, 1, new MyProvider());
CrawljaxConfiguration config =
CrawljaxConfiguration
.builderFor("http://example.com")
.setBrowserConfig(browserConfg)
.build();
CrawlSession runner = new CrawljaxRunner(config).call();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment