本文整理了Java中org.openqa.selenium.WebDriver.navigate()
方法的一些代码示例,展示了WebDriver.navigate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebDriver.navigate()
方法的具体详情如下:
包路径:org.openqa.selenium.WebDriver
类名称:WebDriver
方法名:navigate
[英]An abstraction allowing the driver to access the browser's history and to navigate to a given URL.
[中]一种抽象,允许驱动程序访问浏览器的历史记录并导航到给定的URL。
代码示例来源:origin: galenframework/galen
@Override
public void refresh() {
driver.navigate().refresh();
}
代码示例来源:origin: apache/geode
@Override
public void before() throws Throwable {
setUpWebDriver();
try {
driver.get(getPulseURL() + "login.html");
} catch (Exception e) {
e.printStackTrace();
System.out.println("before: driver get exception " + e.getMessage());
throw e;
}
if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) {
try {
login();
} catch (Exception e) {
e.printStackTrace();
System.out.println("before: login exception " + e.getMessage());
throw e;
}
}
driver.navigate().refresh();
}
代码示例来源:origin: selenide/selenide
public void refresh(Driver driver) {
driver.getWebDriver().navigate().refresh();
}
}
代码示例来源:origin: selenide/selenide
public void back(Driver driver) {
driver.getWebDriver().navigate().back();
}
代码示例来源:origin: selenide/selenide
public void forward(Driver driver) {
driver.getWebDriver().navigate().forward();
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testAccountChooserPopulatesUsernameNotEmailWhenOriginIsUAAorLDAP() throws Exception {
String userUAA = "{\"userId\":\"1\",\"username\":\"userUAA\",\"origin\":\"uaa\",\"email\":\"user@uaa.org\"}";
String userLDAP = "{\"userId\":\"2\",\"username\":\"userLDAP\",\"origin\":\"ldap\",\"email\":\"user@ldap.org\"}";
String userExternal = "{\"userId\":\"3\",\"username\":\"userExternal\",\"origin\":\"external\",\"email\":\"user@external.org\"}";
String zoneUrl = createDiscoveryZone();
webDriver.get(zoneUrl);
webDriver.manage().deleteAllCookies();
JavascriptExecutor js = (JavascriptExecutor) webDriver;
js.executeScript("document.cookie = \"Saved-Account-1=" + URLEncoder.encode(userUAA, StandardCharsets.UTF_8.name()) + ";path=/;domain=testzone3.localhost\"");
js.executeScript("document.cookie = \"Saved-Account-2=" + URLEncoder.encode(userLDAP, StandardCharsets.UTF_8.name()) + ";path=/;domain=testzone3.localhost\"");
js.executeScript("document.cookie = \"Saved-Account-3=" + URLEncoder.encode(userExternal, StandardCharsets.UTF_8.name()) + ";path=/;domain=testzone3.localhost\"");
webDriver.navigate().refresh();
assertEquals(3, webDriver.findElements(By.cssSelector("span.email-address")).size());
webDriver.findElement(By.xpath("//span[contains(text(), 'userUAA')]")).click();
assertEquals("userUAA", webDriver.findElement(By.id("username")).getAttribute("value"));
webDriver.navigate().back();
webDriver.findElement(By.xpath("//span[contains(text(), 'userLDAP')]")).click();
assertEquals("userLDAP", webDriver.findElement(By.id("username")).getAttribute("value"));
webDriver.navigate().back();
webDriver.findElement(By.xpath("//span[contains(text(), 'userExternal')]")).click();
assertEquals("user@external.org", webDriver.findElement(By.id("username")).getAttribute("value"));
webDriver.manage().deleteAllCookies();
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testBannerFunctionalityInDiscoveryPage() {
String zoneId = "testzone3";
RestTemplate identityClient = IntegrationTestUtils.getClientCredentialsTemplate(
IntegrationTestUtils.getClientCredentialsResource(baseUrl, new String[]{"zones.write", "zones.read", "scim.zones"}, "identity", "identitysecret")
);
IdentityZoneConfiguration config = new IdentityZoneConfiguration();
config.setIdpDiscoveryEnabled(true);
Banner banner = new Banner();
banner.setText("test banner");
banner.setBackgroundColor("#444");
banner.setTextColor("#111");
config.setBranding(new BrandingInformation());
config.getBranding().setBanner(banner);
IntegrationTestUtils.createZoneOrUpdateSubdomain(identityClient, baseUrl, zoneId, zoneId, config);
String zoneUrl = baseUrl.replace("localhost",zoneId+".localhost");
webDriver.get(zoneUrl);
webDriver.manage().deleteAllCookies();
webDriver.navigate().refresh();
assertEquals("test banner", webDriver.findElement(By.cssSelector(".banner-header span")).getText());
assertEquals("rgba(68, 68, 68, 1)", webDriver.findElement(By.cssSelector(".banner-header")).getCssValue("background-color"));
assertEquals("rgba(17, 17, 17, 1)", webDriver.findElement(By.cssSelector(".banner-header span")).getCssValue("color"));
String base64Val = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAATBJREFUeNqk008og3Ecx/HNnrJSu63kIC5qKRe7KeUiOSulTHJUTrsr0y5ycFaEgyQXElvt5KDYwU0uO2hSUy4KoR7v7/qsfmjPHvzq1e/XU8/39/3zPFHf9yP/WV7jED24nGRbxDFWUAsToM05zyKFLG60d/wmQBxWzwyOlMU1phELEyCmtPeRQRoVbKOM0VYB6q0QW+3IYQpJFFDEYFCAiMqwNY857Ko3SxjGBTbRXb+xMUamcMbWh148YwJvOHSCdyqTAdxZo72ADGwKT98C9CChcxUPQSVYLz50toae4Fy9WcAISl7AiN/RhS1N5RV5rOLxx5eom90pvGAI/VjHMm6bfspK18a1gXvsqM41XDVL052C1Tim56cYd/rR+mdSrXGluxfm5S8Z/HV9CjAAvQZLXoa5mpgAAAAASUVORK5CYII=";
banner.setLogo(base64Val);
IntegrationTestUtils.createZoneOrUpdateSubdomain(identityClient, baseUrl, zoneId, zoneId, config);
webDriver.get(zoneUrl);
assertEquals("data:image/png;base64," + base64Val, webDriver.findElement(By.cssSelector(".banner-header img")).getAttribute("src"));
assertEquals(2, webDriver.findElement(By.cssSelector(".banner-header")).findElements(By.xpath(".//*")).size());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testBannerBackgroundIsHiddenIfNoTextOrImage() {
String zoneId = "testzone3";
RestTemplate identityClient = IntegrationTestUtils.getClientCredentialsTemplate(
IntegrationTestUtils.getClientCredentialsResource(baseUrl, new String[]{"zones.write", "zones.read", "scim.zones"}, "identity", "identitysecret")
);
IdentityZoneConfiguration config = new IdentityZoneConfiguration();
config.setIdpDiscoveryEnabled(true);
Banner banner = new Banner();
banner.setLink("http://example.com");
banner.setBackgroundColor("#444");
banner.setTextColor("#111");
config.setBranding(new BrandingInformation());
config.getBranding().setBanner(banner);
IntegrationTestUtils.createZoneOrUpdateSubdomain(identityClient, baseUrl, zoneId, zoneId, config);
String zoneUrl = baseUrl.replace("localhost",zoneId+".localhost");
webDriver.get(zoneUrl);
webDriver.manage().deleteAllCookies();
webDriver.navigate().refresh();
assertEquals(0, webDriver.findElements(By.cssSelector(".banner-header")).size());
}
代码示例来源:origin: selenide/selenide
private void navigateTo(SelenideDriver driver, String url,
AuthenticationType authenticationType, String domain, String login, String password) {
checkThatProxyIsEnabled(driver.config());
url = absoluteUrl(driver.config(), url);
url = appendBasicAuthIfNeeded(driver.config(), url, authenticationType, domain, login, password);
SelenideLog log = SelenideLogger.beginStep("open", url);
try {
WebDriver webDriver = driver.getAndCheckWebDriver();
beforeNavigateTo(driver.config(), driver.getProxy(), authenticationType, domain, login, password);
webDriver.navigate().to(url);
SelenideLogger.commitStep(log, PASS);
}
catch (WebDriverException e) {
SelenideLogger.commitStep(log, e);
e.addInfo("selenide.url", url);
e.addInfo("selenide.baseUrl", driver.config().baseUrl());
throw e;
}
catch (RuntimeException | Error e) {
SelenideLogger.commitStep(log, e);
throw e;
}
}
代码示例来源:origin: TEAMMATES/teammates
@Override
public void beforeRetry() {
browser.driver.navigate().back();
}
});
代码示例来源:origin: TEAMMATES/teammates
/** Equivalent to pressing the 'back' button of the browser. <br>
* Fails if the page content does not match content expected in a page of
* the type indicated by the parameter {@code typeOfPreviousPage}.
*/
public <T extends AppPage> T goToPreviousPage(Class<T> typeOfPreviousPage) {
browser.driver.navigate().back();
waitForPageToLoad();
return changePageType(typeOfPreviousPage);
}
代码示例来源:origin: com.wso2telco.test/uitest-framework
@Override
public Navigation navigate() {
// TODO Auto-generated method stub
return driver.navigate();
}
代码示例来源:origin: com.atlassian.selenium/atlassian-webdriver-core
@Nonnull
@Override
public BrowserEngine reloadPage()
{
webDriver.navigate().refresh();
return this;
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui
@Override
public Boolean apply(WebDriver driver)
{
driver.navigate().refresh();
return Boolean.valueOf(pattern.matcher(getContent()).matches());
}
});
代码示例来源:origin: org.nuxeo.runtime/nuxeo-runtime-test
public void to(String path) {
if (path.contains("://")) {
driver.get(path);
} else {
try {
URL url = new URL(new URL(config.getHome()), path);
driver.navigate().to(url);
} catch (MalformedURLException e) {
throw new WebDriverException(e);
}
}
}
代码示例来源:origin: qaprosoft/carina
/**
* Go back in browser.
*/
public void navigateBack() {
getDriver().navigate().back();
Messager.BACK.info();
}
代码示例来源:origin: qaprosoft/carina
/**
* Refresh browser.
*/
public void refresh() {
getDriver().navigate().refresh();
Messager.REFRESH.info();
}
代码示例来源:origin: net.thucydides/thucydides-core
public Navigation navigate() {
if (!isEnabled()) {
return new NavigationStub();
}
return getProxiedDriver().navigate();
}
代码示例来源:origin: com.epam.jdi/jdi-uitest-web
/**
* Go back to previous page
*/
@Step
public void back() {
invoker.doJAction("Go back to previous page",
() -> getDriver().navigate().back());
}
代码示例来源:origin: hamvocke/spring-testing
@Test
public void helloPageHasTextHelloWorld(){
driver.navigate().to(String.format("http://localhost:%s/hello", port));
WebElement body = driver.findElement(By.tagName("body"));
assertThat(body.getText(), containsString("Hello World!"));
}
}
内容来源于网络,如有侵权,请联系作者删除!