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

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

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

By.id介绍

暂无

代码示例

代码示例来源:origin: selenide/selenide

/**
 * @see By#id(java.lang.String)
 * @since 3.1
 */
public static By byId(String id) {
 return By.id(id);
}

代码示例来源:origin: apache/geode

private WebElement waitForElementById(final String id, int timeoutInSeconds) {
  WebElement element =
    (new WebDriverWait(driver, timeoutInSeconds, 1000))
      .until((ExpectedCondition<WebElement>) d -> d.findElement(By.id(id)));
  assertNotNull(element);
  return element;
 }
}

代码示例来源:origin: apache/geode

private void login() {
 WebElement userNameElement = waitForElementById("user_name", 60);
 WebElement passwordElement = waitForElementById("user_password");
 userNameElement.sendKeys(username);
 passwordElement.sendKeys(password);
 passwordElement.submit();
 driver.get(getPulseURL() + "clusterDetail.html");
 WebElement userNameOnPulsePage =
   (new WebDriverWait(driver, 30, 1000)).until(
     (ExpectedCondition<WebElement>) d -> d.findElement(By.id("userName")));
 assertNotNull(userNameOnPulsePage);
}

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

private void loginThroughDiscovery(String userEmail, String password) {
    webDriver.findElement(By.id("email")).sendKeys(userEmail);
    webDriver.findElement(By.cssSelector(".form-group input[value='Next']")).click();
    webDriver.findElement(By.id("password")).sendKeys(password);
    webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
  }
}

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

public void bootVersion(String text) {
  this.form.findElement(By.id("bootVersion")).sendKeys(text);
  this.form.click();
}

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

@Test
public void testFrameReportsChangedWhenSameUser_whenLoggedOut() throws UnsupportedEncodingException, InterruptedException {
  webDriver.get(testPage);
  webDriver.findElement(By.id("sameUser")).click();
  assertMessage("unchanged");
}

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

@Test
public void testFrameReportsChangedWhenNoUser_whenLoggedOut() throws UnsupportedEncodingException, InterruptedException {
  webDriver.get(testPage);
  webDriver.findElement(By.id("noUser")).click();
  assertMessage("unchanged");
}

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

@Test
public void testFrameReportsErrorWhenSendingDifferentUser_whenLoggedOut() throws UnsupportedEncodingException, InterruptedException {
  webDriver.get(testPage);
  webDriver.findElement(By.id("wrongClient")).click();
  assertMessage("error");
}

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

@Test
public void testFrameReportsChangedWhenDifferentUser_whenLoggedOut() throws UnsupportedEncodingException, InterruptedException {
  webDriver.get(testPage);
  webDriver.findElement(By.id("differentUser")).click();
  assertMessage("changed");
}

代码示例来源:origin: galenframework/galen

private static By convertToBy(Locator locator) {
    if ("xpath".equals(locator.getLocatorType())) {
      return By.xpath(locator.getLocatorValue());
    }
    else if ("id".equals(locator.getLocatorType())) {
      return By.id(locator.getLocatorValue());
    }
    else if ("css".equals(locator.getLocatorType())) {
      return By.cssSelector(locator.getLocatorValue());
    }
    else return null;
  }
}

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

public void description(String text) {
  this.form.findElement(By.id("description")).clear();
  this.form.findElement(By.id("description")).sendKeys(text);
}

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

public void groupId(String text) {
  this.form.findElement(By.id("groupId")).clear();
  this.form.findElement(By.id("groupId")).sendKeys(text);
}

代码示例来源: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

@Test
public void testFrameReportsChangedWhenNoUser_whenLoggedIn() throws UnsupportedEncodingException, InterruptedException {
  doLogin();
  webDriver.get(testPage);
  webDriver.findElement(By.id("noUser")).click();
  assertMessage("changed");
}

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

@Test
public void testFrameReportsUnchangedWhenSendingDifferentUser_whenLoggedIn() throws UnsupportedEncodingException, InterruptedException {
  doLogin();
  webDriver.get(testPage);
  webDriver.findElement(By.id("differentUser")).click();
  assertMessage("changed");
}

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

@Test
public void testFrameReportsErrorWhenSendingDifferentUser_whenLoggedIn() throws UnsupportedEncodingException, InterruptedException {
  doLogin();
  webDriver.get(testPage);
  webDriver.findElement(By.id("wrongClient")).click();
  assertMessage("error");
}

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

@Test
public void testFrameReportsUnchangedWhenSendingSameUser_whenLoggedIn() throws UnsupportedEncodingException, InterruptedException {
  doLogin();
  webDriver.get(testPage);
  webDriver.findElement(By.id("sameUser")).click();
  assertMessage("unchanged");
}

代码示例来源: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

@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 testDisplayIdentityZoneNameOnRegisterPage() {
  performLogin(username);
  assertEquals(zoneUrl + "/login/mfa/register", webDriver.getCurrentUrl());
  assertEquals(webDriver.findElement(By.id("mfa-identity-zone")).getText(), mfaZone.getName());
}

相关文章