org.openqa.selenium.By.tagName()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(12.6k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中org.openqa.selenium.By.tagName()方法的一些代码示例,展示了By.tagName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。By.tagName()方法的具体详情如下:
包路径:org.openqa.selenium.By
类名称:By
方法名:tagName

By.tagName介绍

暂无

代码示例

代码示例来源:origin: cloudfoundry/uaa

@Test
  public void testMethodNotAllowedRoutedToErrorPage() throws Exception {
    webDriver.get(baseUrl + "/authenticate");

    Assert.assertTrue("Check if on the error page", webDriver.findElement(By.tagName("h2")).getText().contains("Uh oh."));
    Assert.assertTrue("Check if on the error page", webDriver.findElement(By.tagName("h2")).getText().contains("Something went amiss."));
  }
}

代码示例来源:origin: cloudfoundry/uaa

@Test
  public void testHealthz() throws Exception {
    webDriver.get(baseUrl + "/healthz");
    Assert.assertEquals("ok", webDriver.findElement(By.tagName("body")).getText());
  }
}

代码示例来源:origin: cloudfoundry/uaa

private String startCreateUserFlow(String secret) {
  String userEmail = "user" + new SecureRandom().nextInt() + "@example.com";
  webDriver.get(baseUrl + "/");
  webDriver.findElement(By.xpath("//*[text()='Create account']")).click();
  assertEquals("Create your account", webDriver.findElement(By.tagName("h1")).getText());
  webDriver.findElement(By.name("email")).sendKeys(userEmail);
  webDriver.findElement(By.name("password")).sendKeys(secret);
  webDriver.findElement(By.name("password_confirmation")).sendKeys(secret);
  webDriver.findElement(By.xpath("//input[@value='Send activation link']")).click();
  return userEmail;
}

代码示例来源:origin: cloudfoundry/uaa

@Test
public void testMessage() throws Exception {
  Assert.assertEquals("Where to?", webDriver.findElement(By.tagName("h1")).getText());
}

代码示例来源: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 testNoZoneFound() throws Exception {
  assertTrue("Expected testzone1/2/3/4/doesnotexist.localhost to resolve to 127.0.0.1", doesSupportZoneDNS());
  webDriver.get(baseUrl.replace("localhost","testzonedoesnotexist.localhost") + "/login");
  assertEquals("The subdomain does not map to a valid identity zone.",webDriver.findElement(By.tagName("p")).getText());
}

代码示例来源:origin: spring-io/initializr

public void advanced() {
  this.form.findElement(By.cssSelector(".tofullversion"))
      .findElement(By.tagName("a")).click();
}

代码示例来源:origin: cloudfoundry/uaa

@Test
public void testInsecurePasswordDisplaysErrorMessage() throws Exception {
  String code = createInvitation();
  webDriver.get(baseUrl + "/invitations/accept?code=" + code);
  assertEquals("Create your account", webDriver.findElement(By.tagName("h1")).getText());
  String newPassword = new RandomValueStringGenerator(260).generate();
  webDriver.findElement(By.name("password")).sendKeys(newPassword);
  webDriver.findElement(By.name("password_confirmation")).sendKeys(newPassword);
  webDriver.findElement(By.xpath("//input[@value='Create account']")).click();
  assertThat(webDriver.findElement(By.cssSelector(".alert-error")).getText(), containsString("Password must be no more than 255 characters in length."));
  webDriver.findElement(By.name("password"));
  webDriver.findElement(By.name("password_confirmation"));
}

代码示例来源:origin: testcontainers/testcontainers-java

@Test
  public void testWebDriverToNginxContainerAccessViaContainerLink() {
    RemoteWebDriver driver = chrome.getWebDriver();

    driver.get("http://nginx/");

    assertEquals("Using selenium, an HTTP GET from the nginx server returns the index.html from the custom content directory", "This worked", driver.findElement(By.tagName("body")).getText());
  }
}

代码示例来源:origin: cloudfoundry/uaa

@Test
public void resetPassword_with_clientRedirect() throws Exception {
  webDriver.get(baseUrl + "/forgot_password?client_id=" + scimClientId + "&redirect_uri=http://example.redirect.com");
  Assert.assertEquals("Reset Password", webDriver.findElement(By.tagName("h1")).getText());
  int receivedEmailSize = simpleSmtpServer.getReceivedEmailSize();
  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());
  assertEquals(receivedEmailSize + 1, simpleSmtpServer.getReceivedEmailSize());
  Iterator receivedEmail = simpleSmtpServer.getReceivedEmail();
  SmtpMessage message = (SmtpMessage) receivedEmail.next();
  receivedEmail.remove();
  assertEquals(email, message.getHeaderValue("To"));
  assertThat(message.getBody(), containsString("Reset your password"));
  Assert.assertEquals("Please check your email for a reset password link.", webDriver.findElement(By.cssSelector(".instructions-sent")).getText());
  // Click link in email
  String link = testClient.extractLink(message.getBody());
  assertFalse(contains(link, "@"));
  assertFalse(contains(link, "%40"));
  webDriver.get(link);
  webDriver.findElement(By.name("password")).sendKeys("new_password");
  webDriver.findElement(By.name("password_confirmation")).sendKeys("new_password");
  webDriver.findElement(By.xpath("//input[@value='Create new password']")).click();
  assertEquals(baseUrl + "/login?success=password_reset&form_redirect_uri=http://example.redirect.com", webDriver.getCurrentUrl());
}

代码示例来源:origin: cloudfoundry/uaa

@Test
public void testClientInitiatedSignup() throws Exception {
  String userEmail = "user" + new SecureRandom().nextInt() + "@example.com";
  webDriver.get(baseUrl + "/create_account?client_id=app");
  assertEquals("Create your account", webDriver.findElement(By.tagName("h1")).getText());
  int receivedEmailSize = simpleSmtpServer.getReceivedEmailSize();
  webDriver.findElement(By.name("email")).sendKeys(userEmail);
  webDriver.findElement(By.name("password")).sendKeys(SECRET);
  webDriver.findElement(By.name("password_confirmation")).sendKeys(SECRET);
  webDriver.findElement(By.xpath("//input[@value='Send activation link']")).click();
  assertEquals(receivedEmailSize + 1, simpleSmtpServer.getReceivedEmailSize());
  Iterator receivedEmail = simpleSmtpServer.getReceivedEmail();
  SmtpMessage message = (SmtpMessage) receivedEmail.next();
  receivedEmail.remove();
  assertEquals(userEmail, message.getHeaderValue("To"));
  assertThat(message.getBody(), containsString("Activate your account"));
  assertEquals("Please check email for an activation link.", webDriver.findElement(By.cssSelector(".instructions-sent")).getText());
  String link = testClient.extractLink(message.getBody());
  assertFalse(isEmpty(link));
  webDriver.get(link);
  assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), not(containsString("Where to?")));
  webDriver.findElement(By.name("username")).sendKeys(userEmail);
  webDriver.findElement(By.name("password")).sendKeys(SECRET);
  webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
  // Authorize the app for some scopes
  assertEquals("Application Authorization", webDriver.findElement(By.cssSelector("h1")).getText());
  webDriver.findElement(By.xpath("//button[text()='Authorize']")).click();
  assertEquals("Sample Home Page", webDriver.findElement(By.cssSelector("h1")).getText());
}

代码示例来源:origin: cloudfoundry/uaa

@Test
public void testUserInitiatedSignup() throws Exception {
  int receivedEmailSize = simpleSmtpServer.getReceivedEmailSize();
  String userEmail = startCreateUserFlow(SECRET);
  assertEquals(receivedEmailSize + 1, simpleSmtpServer.getReceivedEmailSize());
  Iterator receivedEmail = simpleSmtpServer.getReceivedEmail();
  SmtpMessage message = (SmtpMessage) receivedEmail.next();
  receivedEmail.remove();
  assertEquals(userEmail, message.getHeaderValue("To"));
  String body = message.getBody();
  assertThat(body, containsString("Activate your account"));
  assertEquals("Create your account", webDriver.findElement(By.tagName("h1")).getText());
  assertEquals("Please check email for an activation link.", webDriver.findElement(By.cssSelector(".instructions-sent")).getText());
  String link = testClient.extractLink(body);
  assertFalse(isEmpty(link));
  assertFalse(contains(link, "@"));
  assertFalse(contains(link, "%40"));
  webDriver.get(link);
  assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), not(containsString("Where to?")));
  webDriver.findElement(By.name("username")).sendKeys(userEmail);
  webDriver.findElement(By.name("password")).sendKeys(SECRET);
  webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
  assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), containsString("Where to?"));
}

代码示例来源:origin: cloudfoundry/uaa

Assert.assertEquals("Reset Password", webDriver.findElement(By.tagName("h1")).getText());
Assert.assertEquals("Instructions Sent", webDriver.findElement(By.tagName("h1")).getText());

代码示例来源:origin: cloudfoundry/uaa

assertEquals("Create your account", webDriver.findElement(By.tagName("h1")).getText());
webDriver.findElement(By.name("password")).sendKeys("secr3T");
webDriver.findElement(By.name("password_confirmation")).sendKeys("secr3T");

代码示例来源:origin: TEAMMATES/teammates

private int getEvalRowId(String name) {
  int id = 0;
  while (isElementPresent(By.id("evaluation" + id))) {
    WebElement element = browser.driver.findElement(By.id("evaluation" + id));
    WebElement text = element.findElement(By.tagName("td"));
    if (text.getText().contains(name)) {
      return id;
    }
    id++;
  }
  return -1;
}

代码示例来源:origin: TEAMMATES/teammates

public void clickCopyTableRadioButtonAtRow(int rowIndex) {
  WebElement button = browser.driver.findElement(By.id("copyTableModal"))
                  .findElements(By.tagName("tr"))
                  .get(rowIndex + 1).findElement(By.tagName("input"));
  click(button);
}

代码示例来源:origin: TEAMMATES/teammates

public boolean isRadioButtonChecked(int rowIndex) {
  WebElement button = browser.driver.findElement(By.id("copyTableModal"))
                  .findElements(By.tagName("tr"))
                  .get(rowIndex + 1).findElement(By.tagName("input"));
  return button.isSelected();
}

代码示例来源:origin: TEAMMATES/teammates

/**
 * Returns the value of the header located at {@code (row, column)}
 *         from the nth(0-index-based) table (which is of type {@code class=table}) in the page.
 */
public String getHeaderValueFromDataTable(int tableNum, int row, int column) {
  WebElement tableElement = browser.driver.findElements(By.className("table")).get(tableNum);
  WebElement trElement = tableElement.findElements(By.tagName("tr")).get(row);
  WebElement tdElement = trElement.findElements(By.tagName("th")).get(column);
  return tdElement.getText();
}

代码示例来源:origin: TEAMMATES/teammates

/**
 * Returns the number of rows from the nth(0-index-based) table
 *         (which is of type {@code class=table}) in the page.
 */
public int getNumberOfRowsFromDataTable(int tableNum) {
  WebElement tableElement = browser.driver.findElements(By.className("table")).get(tableNum);
  return tableElement.findElements(By.tagName("tr")).size();
}

代码示例来源:origin: TEAMMATES/teammates

public void clickVisibilityOptionForResponseCommentAndSave(String idString, int numOfTheCheckbox) {
  String idSuffix = idString.substring(18);
  WebElement commentRow = browser.driver.findElement(By.id(idString));
  click(commentRow.findElements(By.tagName("a")).get(1));
  WebElement commentEditForm = browser.driver.findElement(By.id("responseCommentEditForm" + idSuffix));
  click(commentRow.findElement(By.id("frComment-visibility-options-trigger" + idSuffix)));
  click(commentRow.findElements(By.cssSelector("input[type='checkbox']")).get(numOfTheCheckbox));
  click(commentEditForm.findElement(By.className("col-sm-offset-5")).findElement(By.tagName("a")));
  ThreadHelper.waitFor(1000);
}

相关文章