本文整理了Java中org.openqa.selenium.WebDriver.getCurrentUrl()
方法的一些代码示例,展示了WebDriver.getCurrentUrl()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebDriver.getCurrentUrl()
方法的具体详情如下:
包路径:org.openqa.selenium.WebDriver
类名称:WebDriver
方法名:getCurrentUrl
[英]Get a string representing the current URL that the browser is looking at.
[中]获取表示浏览器正在查看的当前URL的字符串。
代码示例来源:origin: galenframework/galen
@Override
public String getUrl() {
return driver.getCurrentUrl();
}
代码示例来源:origin: spring-io/initializr
public HomePage submit() {
String url = this.driver.getCurrentUrl();
this.form.findElement(By.name("generate-project")).click();
assertThat(this.driver.getCurrentUrl()).isEqualTo(url);
return this;
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testMfaVerifyPageWithoutLoggingIn() {
webDriver.get(zoneUrl + "/logout.do");
webDriver.get(zoneUrl + "/login/mfa/verify");
assertEquals(zoneUrl + "/login", webDriver.getCurrentUrl());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testMfaRegisterPageWithoutLoggingIn() {
webDriver.get(zoneUrl + "/logout.do");
webDriver.get(zoneUrl + "/login/mfa/register");
assertEquals(zoneUrl + "/login", webDriver.getCurrentUrl());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testQRCodeValidation() {
performLogin(username);
assertEquals(zoneUrl + "/login/mfa/register", webDriver.getCurrentUrl());
webDriver.findElement(By.id("Next")).click();
assertEquals(zoneUrl + "/login/mfa/verify", webDriver.getCurrentUrl());
webDriver.findElement(By.name("code")).sendKeys("1111111111111111112222");
webDriver.findElement(By.id("verify_code_btn")).click();
assertEquals("Incorrect code, please try again.", webDriver.findElement(By.cssSelector("form .error-color")).getText());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testDisplayIdentityZoneNameOnVerifyPage() {
performLogin(username);
webDriver.findElement(By.id("Next")).click();
assertEquals(zoneUrl + "/login/mfa/verify", webDriver.getCurrentUrl());
assertEquals(webDriver.findElement(By.id("mfa-identity-zone")).getText(), mfaZone.getName());
webDriver.findElement(By.id("verify_code_btn")).click();
assertEquals(webDriver.findElement(By.id("mfa-identity-zone")).getText(), mfaZone.getName());
}
代码示例来源:origin: cloudfoundry/uaa
private void navigateToForcePasswordChange() {
updateUserToForcePasswordChange(restTemplate, baseUrl, adminAccessToken, userId);
webDriver.get(baseUrl+"/login");
webDriver.findElement(By.name("username")).sendKeys(userEmail);
webDriver.findElement(By.name("password")).sendKeys("secr3T");
webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
assertThat(webDriver.findElement(By.cssSelector("h1")).getText(),
containsString("Force Change Password"));
assertEquals(baseUrl+"/force_password_change", webDriver.getCurrentUrl());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testQRCodeScreen() throws Exception {
performLogin(username);
assertEquals(zoneUrl + "/login/mfa/register", webDriver.getCurrentUrl());
String imageSrc = webDriver.findElement(By.id("qr")).getAttribute("src");
String secretKey = getSecretFromQrImageString(imageSrc);
webDriver.findElement(By.id("Next")).click();
verifyCodeOnRegistration(secretKey, "/");
}
代码示例来源:origin: cloudfoundry/uaa
private void finishPasswordReset(String username, String email) {
String link = getPasswordResetLink(email);
webDriver.get(link);
// Successfully choose password
webDriver.findElement(By.name("password")).sendKeys("newsecr3T");
webDriver.findElement(By.name("password_confirmation")).sendKeys("newsecr3T");
webDriver.findElement(By.xpath("//input[@value='Create new password']")).click();
assertThat(webDriver.getCurrentUrl(), is(baseUrl + "/login?success=password_reset"));
webDriver.findElement(By.name("username")).sendKeys(username);
webDriver.findElement(By.name("password")).sendKeys("newsecr3T");
webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), containsString("Where to?"));
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testRedirectForHandleForcePasswordChange() throws Exception {
updateUserToForcePasswordChange(restTemplate, baseUrl, adminAccessToken, userId);
webDriver.get(baseUrl+"/profile");
assertEquals(baseUrl+"/login", webDriver.getCurrentUrl());
webDriver.findElement(By.name("username")).sendKeys(userEmail);
webDriver.findElement(By.name("password")).sendKeys("secr3T");
webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
webDriver.findElement(By.name("password")).sendKeys("newsecr3T");
webDriver.findElement(By.name("password_confirmation")).sendKeys("newsecr3T");
webDriver.findElement(By.xpath("//input[@value='Create new password']")).click();
assertEquals(baseUrl+"/profile", webDriver.getCurrentUrl());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testHandleForceChangingPassword() throws Exception {
navigateToForcePasswordChange();
webDriver.findElement(By.name("password")).sendKeys("newsecr3T");
webDriver.findElement(By.name("password_confirmation")).sendKeys("newsecr3T");
webDriver.findElement(By.xpath("//input[@value='Create new password']")).click();
assertEquals(baseUrl+"/", webDriver.getCurrentUrl());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testHandleForceChangingPasswordWithNewPasswordSameAsOld() throws Exception {
navigateToForcePasswordChange();
webDriver.findElement(By.name("password")).sendKeys("secr3T");
webDriver.findElement(By.name("password_confirmation")).sendKeys("secr3T");
webDriver.findElement(By.xpath("//input[@value='Create new password']")).click();
assertEquals(baseUrl+"/force_password_change", webDriver.getCurrentUrl());
assertThat(webDriver.findElement(By.cssSelector(".error-message")).getText(),
containsString("Your new password cannot be the same as the old password."));
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testHandleForcePasswordChangeInvalidConfirmation() throws Exception {
navigateToForcePasswordChange();
webDriver.findElement(By.name("password")).sendKeys("newsecr3T");
webDriver.findElement(By.name("password_confirmation")).sendKeys("invalid");
webDriver.findElement(By.xpath("//input[@value='Create new password']")).click();
assertEquals(baseUrl+"/force_password_change", webDriver.getCurrentUrl());
assertThat(webDriver.findElement(By.cssSelector(".error-message")).getText(),
containsString("Passwords must match and not be empty."));
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testHandleForcePasswordChangeEmptyConfirmation() throws Exception {
navigateToForcePasswordChange();
webDriver.findElement(By.name("password")).sendKeys("newsecr3T");
webDriver.findElement(By.xpath("//input[@value='Create new password']")).click();
assertEquals(baseUrl+"/force_password_change", webDriver.getCurrentUrl());
assertThat(webDriver.findElement(By.cssSelector(".error-message")).getText(),
containsString("Passwords must match and not be empty."));
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void checkAccessForTotpPage() throws Exception {
webDriver.get(zoneUrl + "/logout.do");
webDriver.manage().deleteAllCookies();
webDriver.get(zoneUrl + "/login/mfa/register");
assertEquals(zoneUrl + "/login", webDriver.getCurrentUrl());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testDisplayIdentityZoneNameOnRegisterPage() {
performLogin(username);
assertEquals(zoneUrl + "/login/mfa/register", webDriver.getCurrentUrl());
assertEquals(webDriver.findElement(By.id("mfa-identity-zone")).getText(), mfaZone.getName());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testLoginReloadRetainsFormRedirect() {
String redirectUri = "http://expected.com";
webDriver.get(baseUrl + "/oauth/authorize?client_id=test&redirect_uri="+redirectUri);
((JavascriptExecutor)webDriver).executeScript("document.getElementsByName('X-Uaa-Csrf')[0].value=''");
webDriver.manage().deleteCookieNamed("JSESSIONID");
webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
assertThat(webDriver.getCurrentUrl(), Matchers.containsString("/login"));
assertThat(webDriver.findElement(By.name("form_redirect_uri")).getAttribute("value"), Matchers.containsString("redirect_uri="+redirectUri));
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testForcePasswordChangeThatFailsPasswordPolicy() {
navigateToForcePasswordChange();
String invalidNewPassword = new RandomValueStringGenerator(256).generate();
webDriver.findElement(By.name("password")).sendKeys(invalidNewPassword);
webDriver.findElement(By.name("password_confirmation")).sendKeys(invalidNewPassword);
webDriver.findElement(By.xpath("//input[@value='Create new password']")).click();
assertEquals(baseUrl+"/force_password_change", webDriver.getCurrentUrl());
assertThat(webDriver.findElement(By.cssSelector(".error-message")).getText(),
containsString("Password must be no more than 255 characters in length."));
}
代码示例来源:origin: cloudfoundry/uaa
private void verifyCodeOnRegistration(String key, String expectedUrlPath) {
GoogleAuthenticator authenticator = new GoogleAuthenticator(new GoogleAuthenticatorConfig.GoogleAuthenticatorConfigBuilder().build());
Integer verificationCode = authenticator.getTotpPassword(key);
webDriver.findElement(By.name("code")).sendKeys(verificationCode.toString());
webDriver.findElement(By.cssSelector("form button")).click();
assertEquals(zoneUrl + expectedUrlPath, webDriver.getCurrentUrl());
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void defaultLoginPageWithSingleClientRegistrationThenRedirect() {
this.spring.register(OAuth2LoginWithSingleClientRegistrations.class).autowire();
WebTestClient webTestClient = WebTestClientBuilder
.bindToWebFilters(new GitHubWebFilter(), this.springSecurity)
.build();
WebDriver driver = WebTestClientHtmlUnitDriverBuilder
.webTestClientSetup(webTestClient)
.build();
driver.get("http://localhost/");
assertThat(driver.getCurrentUrl()).startsWith("https://github.com/login/oauth/authorize");
}
内容来源于网络,如有侵权,请联系作者删除!