Created
August 6, 2013 13:25
-
-
Save alexnederlof/6164401 to your computer and use it in GitHub Desktop.
Crawljax setup with custom browser builder that sets a Cookie.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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