下面列出了怎么用org.openqa.selenium.PageLoadStrategy的API类实例代码及写法,或者点击链接到github查看源代码。
public void addPageLoadStrategy() {
pageLoadStrategy = new ChoiceBox<>();
pageLoadStrategy.getItems().add(null);
pageLoadStrategy.getItems().addAll(FXCollections.observableArrayList(PageLoadStrategy.values()));
String value = BrowserConfig.instance().getValue(getBrowserName(), "browser-page-load-strategy");
if (value != null)
pageLoadStrategy.getSelectionModel().select(PageLoadStrategy.fromString(value));
advancedPane.addFormField("Page load strategy:", pageLoadStrategy);
}
@Test
public void canSetPageLoadStrategyViaOptions() {
localDriver = new FirefoxDriver(
new FirefoxOptions().setPageLoadStrategy(PageLoadStrategy.NONE));
verifyItIsMarionette(localDriver);
assertThat(localDriver.getCapabilities().getCapability(PAGE_LOAD_STRATEGY)).isEqualTo("none");
}
@Test
public void canInitFirefoxOptionsWithCapabilities() {
FirefoxOptions options = new FirefoxOptions(new ImmutableCapabilities(
MARIONETTE, false,
PAGE_LOAD_STRATEGY, PageLoadStrategy.EAGER,
ACCEPT_INSECURE_CERTS, true));
assertThat(options.isLegacy()).isTrue();
assertThat(options.getCapability(PAGE_LOAD_STRATEGY)).isEqualTo(EAGER);
assertThat(options.getCapability(ACCEPT_INSECURE_CERTS)).isEqualTo(true);
}
@Test
public void canInitFirefoxOptionsWithCapabilitiesThatContainFirefoxOptions() {
FirefoxOptions options = new FirefoxOptions().setLegacy(true).merge(
new ImmutableCapabilities(PAGE_LOAD_STRATEGY, PageLoadStrategy.EAGER));
Capabilities caps = new ImmutableCapabilities(FIREFOX_OPTIONS, options);
FirefoxOptions options2 = new FirefoxOptions(caps);
assertThat(options2.isLegacy()).isTrue();
assertThat(options2.getCapability(PAGE_LOAD_STRATEGY)).isEqualTo(EAGER);
}
@Test
public void canMergeWithoutChangingOriginalObject() {
EdgeHtmlOptions options = new EdgeHtmlOptions();
Map<String, Object> before = options.asMap();
EdgeHtmlOptions merged = options.merge(
new ImmutableCapabilities(CapabilityType.PAGE_LOAD_STRATEGY, PageLoadStrategy.NONE));
// TODO: assertThat(merged).isNotSameAs(options);
// TODO: assertThat(options.asMap()).isEqualTo(before);
assertThat(merged.getCapability(CapabilityType.PAGE_LOAD_STRATEGY)).isEqualTo(PageLoadStrategy.NONE);
}
@Test
public void canMergeWithoutChangingOriginalObject() {
EdgeOptions options = new EdgeOptions();
Map<String, Object> before = options.asMap();
EdgeOptions merged = options.merge(
new ImmutableCapabilities(CapabilityType.PAGE_LOAD_STRATEGY, PageLoadStrategy.NONE));
// TODO: assertThat(merged).isNotSameAs(options);
// TODO: assertThat(options.asMap()).isEqualTo(before);
assertThat(merged.getCapability(CapabilityType.PAGE_LOAD_STRATEGY)).isEqualTo(PageLoadStrategy.NONE);
}
@Override
public PageLoadStrategy getPageLoadStrategy() {
String value = (String) getSettingsFile().getValueOrDefault(getDriverSettingsPath("pageLoadStrategy"), "normal");
return PageLoadStrategy.fromString(value.toLowerCase());
}
public DO setPageLoadStrategy(PageLoadStrategy strategy) {
setCapability(
PAGE_LOAD_STRATEGY,
Require.nonNull("Page load strategy", strategy));
return (DO) this;
}
/**
* Gets WebDriver page load strategy.
* @return initialized {@link PageLoadStrategy}
*/
PageLoadStrategy getPageLoadStrategy();