本文整理了Java中org.openqa.selenium.By.linkText()
方法的一些代码示例,展示了By.linkText()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。By.linkText()
方法的具体详情如下:
包路径:org.openqa.selenium.By
类名称:By
方法名:linkText
暂无
代码示例来源:origin: selenide/selenide
/**
* @see By#linkText(java.lang.String)
* @since 3.1
*/
public static By byLinkText(String linkText) {
return By.linkText(linkText);
}
代码示例来源:origin: spring-projects/spring-security
public WebElement findClientRegistrationByName(String clientName) {
return DefaultLoginPage.this.driver.findElement(By.linkText(clientName));
}
代码示例来源:origin: cloudfoundry/uaa
private void logout() {
webDriver.findElement(By.cssSelector(".dropdown-trigger")).click();
webDriver.findElement(By.linkText("Sign Out")).click();
}
代码示例来源:origin: cloudfoundry/uaa
private void signOut() {
webDriver.findElement(By.xpath("//*[text()='"+userEmail+"']")).click();
webDriver.findElement(By.linkText("Sign Out")).click();
}
代码示例来源:origin: cloudfoundry/uaa
private void changePassword(String originalPassword, String newPassword, String confirmPassword) {
webDriver.findElement(By.xpath("//*[text()='"+userEmail+"']")).click();
webDriver.findElement(By.linkText("Account Settings")).click();
webDriver.findElement(By.linkText("Change Password")).click();
webDriver.findElement(By.name("current_password")).sendKeys(originalPassword);
webDriver.findElement(By.name("new_password")).sendKeys(newPassword);
webDriver.findElement(By.name("confirm_password")).sendKeys(confirmPassword);
webDriver.findElement(By.xpath("//input[@value='Change password']")).click();
}
代码示例来源:origin: cloudfoundry/uaa
private void validateSuccessfulOIDCLogin(String zoneUrl, String userName, String password) {
login(zoneUrl, userName, password);
webDriver.findElement(By.cssSelector(".dropdown-trigger")).click();
webDriver.findElement(By.linkText("Sign Out")).click();
IntegrationTestUtils.validateAccountChooserCookie(zoneUrl, webDriver);
}
代码示例来源:origin: cloudfoundry/uaa
private void beginPasswordReset(String username) {
webDriver.get(baseUrl + "/login");
Assert.assertEquals("Cloud Foundry", webDriver.getTitle());
webDriver.findElement(By.linkText("Reset password")).click();
Assert.assertEquals("Reset Password", webDriver.findElement(By.tagName("h1")).getText());
// Enter email address
webDriver.findElement(By.name("username")).sendKeys(username);
webDriver.findElement(By.xpath("//input[@value='Send reset password link']")).click();
Assert.assertEquals("Instructions Sent", webDriver.findElement(By.tagName("h1")).getText());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testQRCodeScreen_ClickManualAndReturn() throws Exception{
performLogin(username);
assertEquals(zoneUrl + "/login/mfa/register", webDriver.getCurrentUrl());
webDriver.findElement(By.linkText("manual setup instructions")).click();
assertEquals(zoneUrl + "/login/mfa/manual", webDriver.getCurrentUrl());
webDriver.findElement(By.id("Back")).click();
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
@Test
public void testManualMfaRegistrationFlow() {
performLogin(username);
assertEquals(zoneUrl + "/login/mfa/register", webDriver.getCurrentUrl());
webDriver.findElement(By.linkText("manual setup instructions")).click();
assertEquals(zoneUrl + "/login/mfa/manual", webDriver.getCurrentUrl());
String key = webDriver.findElement(By.id("key")).getText();
String account = webDriver.findElement(By.id("account")).getText();
assertFalse("secret not found", key.isEmpty());
assertFalse("account not found", account.isEmpty());
webDriver.findElement(By.id("Next")).click();
assertEquals(zoneUrl + "/login/mfa/verify", webDriver.getCurrentUrl());
verifyCodeOnRegistration(key, "/");
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testManualMfaRegistrationFlow_ClickBackAndManual() {
performLogin(username);
assertEquals(zoneUrl + "/login/mfa/register", webDriver.getCurrentUrl());
webDriver.findElement(By.linkText("manual setup instructions")).click();
assertEquals(zoneUrl + "/login/mfa/manual", webDriver.getCurrentUrl());
webDriver.findElement(By.id("Back")).click();
assertEquals(zoneUrl + "/login/mfa/register", webDriver.getCurrentUrl());
webDriver.findElement(By.linkText("manual setup instructions")).click();
assertEquals(zoneUrl + "/login/mfa/manual", webDriver.getCurrentUrl());
String key = webDriver.findElement(By.id("key")).getText();
String account = webDriver.findElement(By.id("account")).getText();
assertFalse("secret not found", key.isEmpty());
assertFalse("account not found", account.isEmpty());
webDriver.findElement(By.id("Next")).click();
assertEquals(zoneUrl + "/login/mfa/verify", webDriver.getCurrentUrl());
verifyCodeOnRegistration(key, "/");
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testQRCodeScreen_ClickManualClickNextClickBack() throws Exception{
performLogin(username);
assertEquals(zoneUrl + "/login/mfa/register", webDriver.getCurrentUrl());
webDriver.findElement(By.linkText("manual setup instructions")).click();
assertEquals(zoneUrl + "/login/mfa/manual", webDriver.getCurrentUrl());
webDriver.findElement(By.id("Next")).click();
assertEquals(zoneUrl + "/login/mfa/verify", webDriver.getCurrentUrl());
webDriver.findElement(By.id("Back")).click();
assertEquals(zoneUrl + "/login/mfa/register", webDriver.getCurrentUrl());
String imageSrc = webDriver.findElement(By.id("qr")).getAttribute("src");
String secretKey = getSecretFromQrImageString(imageSrc);
assertFalse("secret not found", secretKey.isEmpty());
webDriver.findElement(By.id("Next")).click();
verifyCodeOnRegistration(secretKey, "/");
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void login_with_wrong_keys() throws Exception {
identityProvider.getConfig().setTokenKeyUrl(new URL("https://login.microsoftonline.com/9bc40aaf-e150-4c30-bb3c-a8b3b677266e/discovery/v2.0/keys"));
updateProvider();
webDriver.get(zoneUrl + "/login");
webDriver.findElement(By.linkText("My OIDC Provider")).click();
Assert.assertThat(webDriver.getCurrentUrl(), containsString(baseUrl));
webDriver.findElement(By.name("username")).sendKeys("marissa");
webDriver.findElement(By.name("password")).sendKeys("koala");
webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
Assert.assertThat(webDriver.getCurrentUrl(), containsString(zoneUrl + "/oauth_error?error=There+was+an+error+when+authenticating+against+the+external+identity+provider"));
List<String> cookies = IntegrationTestUtils.getAccountChooserCookies(zoneUrl, webDriver);
assertThat(cookies, not(Matchers.hasItem(startsWith("Saved-Account-"))));
}
代码示例来源:origin: cloudfoundry/uaa
public String testChangeEmail(boolean logout) throws Exception {
signIn(userEmail, "secr3T");
int receivedEmailSize = simpleSmtpServer.getReceivedEmailSize();
webDriver.get(baseUrl + "/profile");
Assert.assertEquals(userEmail, webDriver.findElement(By.cssSelector(".profile .email")).getText());
webDriver.findElement(By.linkText("Change Email")).click();
Assert.assertEquals("Current Email Address: " + userEmail, webDriver.findElement(By.cssSelector(".email-display")).getText());
String newEmail = userEmail.replace("user", "new");
webDriver.findElement(By.name("newEmail")).sendKeys(newEmail);
webDriver.findElement(By.xpath("//input[@value='Send Verification Link']")).click();
assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), containsString("Instructions Sent"));
assertEquals(receivedEmailSize + 1, simpleSmtpServer.getReceivedEmailSize());
Iterator receivedEmail = simpleSmtpServer.getReceivedEmail();
SmtpMessage message = (SmtpMessage) receivedEmail.next();
receivedEmail.remove();
assertEquals(newEmail, message.getHeaderValue("To"));
assertThat(message.getBody(), containsString("Verify your email"));
String link = testClient.extractLink(message.getBody());
assertFalse(contains(link, "@"));
assertFalse(contains(link, "%40"));
if (logout) {
webDriver.get(baseUrl + "/logout.do");
}
webDriver.get(link);
return newEmail;
}
代码示例来源:origin: cloudfoundry/uaa
private void login(String zoneUrl, String userName, String password) {
webDriver.get(zoneUrl + "/logout.do");
webDriver.get(zoneUrl + "/");
Cookie beforeLogin = webDriver.manage().getCookieNamed("JSESSIONID");
assertNotNull(beforeLogin);
assertNotNull(beforeLogin.getValue());
webDriver.findElement(By.linkText("My OIDC Provider")).click();
Assert.assertThat(webDriver.getCurrentUrl(), containsString(baseUrl));
webDriver.findElement(By.name("username")).sendKeys(userName);
webDriver.findElement(By.name("password")).sendKeys(password);
webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
Assert.assertThat(webDriver.getCurrentUrl(), containsString(zoneUrl));
assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), containsString("Where to?"));
Cookie afterLogin = webDriver.manage().getCookieNamed("JSESSIONID");
assertNotNull(afterLogin);
assertNotNull(afterLogin.getValue());
assertNotEquals(beforeLogin.getValue(), afterLogin.getValue());
}
代码示例来源:origin: cloudfoundry/uaa
webDriver.get(baseUrl + "/oauth/authorize?client_id=" + authCodeClientId + "&redirect_uri=http://example.redirect.com&grant_type=authorization_code&response_type=code");
webDriver.findElement(By.linkText("Reset password")).click();
Assert.assertEquals("Reset Password", webDriver.findElement(By.tagName("h1")).getText());
代码示例来源:origin: cloudfoundry/uaa
webDriver.findElement(By.linkText("Revoke Access")).click();
webDriver.findElement(By.linkText("Revoke Access")).click();
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testSingleLogoutWithNoLogoutUrlOnIDP() throws Exception {
SamlIdentityProviderDefinition providerDefinition = createIDPWithNoSLOSConfigured(SAML_ORIGIN);
IdentityProvider<SamlIdentityProviderDefinition> provider = new IdentityProvider();
provider.setIdentityZoneId(OriginKeys.UAA);
provider.setType(OriginKeys.SAML);
provider.setActive(true);
provider.setConfig(providerDefinition);
provider.setOriginKey(providerDefinition.getIdpEntityAlias());
provider.setName("simplesamlphp for uaa");
String zoneAdminToken = getZoneAdminToken(baseUrl, serverRunning);
provider = IntegrationTestUtils.createOrUpdateProvider(zoneAdminToken, baseUrl, provider);
webDriver.get(baseUrl + "/login");
Assert.assertEquals("Cloud Foundry", webDriver.getTitle());
webDriver.findElement(By.xpath("//a[text()='" + provider.getConfig().getLinkText() + "']")).click();
webDriver.findElement(By.xpath("//h2[contains(text(), 'Enter your username and password')]"));
webDriver.findElement(By.name("username")).clear();
webDriver.findElement(By.name("username")).sendKeys(testAccounts.getUserName());
webDriver.findElement(By.name("password")).sendKeys(testAccounts.getPassword());
webDriver.findElement(By.xpath("//input[@value='Login']")).click();
assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), Matchers.containsString("Where to"));
webDriver.findElement(By.cssSelector(".dropdown-trigger")).click();
webDriver.findElement(By.linkText("Sign Out")).click();
webDriver.findElement(By.xpath("//a[text()='" + provider.getConfig().getLinkText() + "']")).click();
assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), Matchers.containsString("Where to"));
}
代码示例来源:origin: cloudfoundry/uaa
webDriver.findElement(By.linkText("My OIDC Provider")).click();
Assert.assertThat(webDriver.getCurrentUrl(), containsString(baseUrl));
webDriver.findElement(By.linkText("SAML Login")).click();
webDriver.findElement(By.xpath("//h2[contains(text(), 'Enter your username and password')]"));
webDriver.findElement(By.name("username")).clear();
代码示例来源:origin: cloudfoundry/uaa
webDriver.findElement(By.linkText("Login with Simple SAML PHP(simplesamlphp)")).click();
webDriver.findElement(By.xpath("//h2[contains(text(), 'Enter your username and password')]"));
webDriver.findElement(By.name("username")).clear();
代码示例来源:origin: cloudfoundry/uaa
webDriver.findElement(By.linkText("My OIDC Provider")).click();
内容来源于网络,如有侵权,请联系作者删除!